expect自动应答  TCL语言

需求1:远程登录到A主机,什么事情也不做

#! /usr/bin/env expect
# 开启一个程序
spawn ssh root@192.144.213.113

# 捕获相关内容
expect {
        "(yes/no)?" { send "yes\r";exp_continue }
        "password:" { send "Lzw18519331036\r" }
}
interact  //交互

 

需求2:远程登录A主机,做一些事情

#! /usr/bin/env expect
set ip 192.144.213.113
set pass Lzw18519331036

spawn ssh root@$ip
expect {
               

}

 

相关文章:

  • 2021-05-30
  • 2022-02-10
  • 2022-03-01
  • 2021-12-17
  • 2021-11-06
  • 2021-08-18
  • 2022-02-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-06-04
  • 2021-07-10
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案