源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

用expect实现的自动登录到多台服务器的shell脚本

  • 时间:2020-10-19 00:50 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:用expect实现的自动登录到多台服务器的shell脚本
[u]复制代码[/u] 代码如下:
#!/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" } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部