欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

用expect實現(xiàn)的自動登錄到多臺服務器的shell腳本

 更新時間:2013年02月25日 15:05:35   作者:  
自動登錄到多臺服務器的shell腳本,用expect來實現(xiàn)的一段代碼,需要的朋友可以參考下
復制代碼 代碼如下:

#!/usr/bin/expect -f
set ipaddress [lindex $argv 0]
set passwd [lindex $argv 1]
set timeout 30
spawn ssh root@$ipaddress
#expect "yes/no"
#send "yesr"
expect "password:"
send "$passwdr"
expect "]*"
send "mkdir -p /tmp/haha/haha2r"
send "exitr"

***************
expect {
"(yes/no)?" {
     send "yesn"
  }
"password:" {
   ....
}
判斷語句
if {$havepass == 0} {
  expect "password:" { send "$pwn" }
}

或者:

expect {
"yes/no" { send "yesr"; exp_continue}
"password:" { send "$passwdr" }
}

相關(guān)文章

最新評論