集群07-expect非交江苏快三平台出租互式批量管理分发项目实战

et 变量江苏快三平台出租Q1157880099名 “ 值 ” #即变量=值

set 变量名 [lindex $arg 0]   #传递参数给变量,变量=$arg 0(代表第一个参数的值)

spawn + 命令   #交互的执行shell命令

expect ...send对:expect等待希望出现的匹配串,对于匹配到的串,send发送命令进行执行

interact 执行完成后保持交互状态,把控制权交给控制台

如远程自动登录脚本:

#!/usr/bin/expect

set host "172.16.1.8"

set password "000000"

set username "demo"

spawn ssh $username@$host

expect {

    "yes/no"{send "yes\r";exp_continue}

    "password:"{send "$password\r"}

}

Interact

猜你喜欢

转载自blog.csdn.net/qq_42422723/article/details/80633337