|
|
分享一个expect的脚本,可以用于Linux机器之间远程执行命令:
#!/usr/bin/expect -fset ipaddress [lindex $argv 0]set user [lindex $argv 1]set passwd [lindex $argv 2]set cmd [lindex $argv 3]set timeout [lindex $argv 4]spawn -noecho ssh $user@$ipaddress $cmdexpect {"yes/no" { send "yes\r";exp_continue}"*assword:" { send "$passwd\r";exp_continue}#"]*" { send "$cmd\r"}}#expect eof |
|