Expect循环登录多台服务器执行命令的脚本
时间:2009-07-24 来源:随风飘来
Expect循环登录多台服务器执行命令的脚本
#!/usr/bin/expect -f
for ((i=1;i<=9;i++))
do
spawn telnet 172.16.$i.1
expect "login*"
send "str010$i\r"
expect "Password:"
send "123456\r"
expect "*>*"
send "exec su -\r"
expect "Password:"
send "123456\r"
expect "*root]#"
send "exit\n"
done
|
for ((i=1;i<=9;i++))
do
spawn telnet 172.16.$i.1
expect "login*"
send "str010$i\r"
expect "Password:"
send "123456\r"
expect "*>*"
send "exec su -\r"
expect "Password:"
send "123456\r"
expect "*root]#"
send "exit\n"
done
相关阅读 更多 +