`

linux expect

 
阅读更多
先安装如下软件
yum install -y expect*
yum install -y tcl*

example
#!/usr/bin/expect -f

set ipaddr "172.16.3.3"

set passwd "taovo@123"

spawn ssh taovo@$ipaddr             

expect {

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

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

}

expect "]#"

send "touch a.txt\r"                     

send "exit\r"

expect eof

exit
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics