您现在的位置是:网站首页> 编程资料编程资料
用expect实现的自动登录到多台服务器的shell脚本_linux shell_
2023-05-26
525人已围观
简介 用expect实现的自动登录到多台服务器的shell脚本_linux 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" }
}
您可能感兴趣的文章:
相关内容
- linux shell 中 2>&1的含义_linux shell_
- linux bash字符串处理大全_linux shell_
- 防止ARP攻击的shell代码_linux shell_
- ubuntu与centos中更换ip的shell代码_linux shell_
- awk中查看包含某两列字符的用法_linux shell_
- 利用kernel提供的接口打印进程号(pid)_linux shell_
- linux shell进度条实现方法_linux shell_
- linux使用select实现精确定时器详解_linux shell_
- 给定链表中间节点指针,删除中间节点的方法_linux shell_
- linux网络编程用到的网络函数详解用和使用示例_linux shell_
