• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    用expect实现的自动登录到多台服务器的shell脚本
    复制代码 代码如下:

    #!/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" }
    }
    您可能感兴趣的文章:
    • 用expect实现ssh自动登录服务器并进行批量管理的实现方法
    • ssh expect自动登录的脚本代码
    • Linux中使用expect脚本实现远程机器自动登录
    • shell脚本通过expect实现自动单边无密登录功能
    • Linux expect实现自动登录脚本实例代码
    上一篇:linux shell 中 2>1的含义
    下一篇:shell脚本从SVN推送到多台服务器的代码
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

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