yyyyyyyyyyyyyyyyyyyy

博客园 首页 新随笔 联系 订阅 管理

expect实现ssh自动登录 

 
  1. #!/usr/local/bin/expect
  2. set PASSWD [lindex $argv 1]
  3. set IP [lindex $argv 0]
  4. set CMD [lindex $argv 2]
  5. spawn ssh $IP $CMD
  6. expect "(yes/no)?" {
  7.         send "yes\r"
  8.         expect "password:"
  9.         send "$PASSWD\r"
  10. } "password:" {send "$PASSWD\r"} "*host " {exit 1}
  11. expect eof
posted on 2015-09-04 12:39  xxxxxxxx1x2xxxxxxx  阅读(254)  评论(0编辑  收藏  举报