#!/usr/bin/expect
set timeout 60
spawn ssh -l guest 210.45.114.190
expect {
"*yes/no*" {send "yes\r"; expect_continue}
"*password*" {send "guest\r"}
}
expect "*guest@node43*"
send "cd SA11011033\r"
expect "*guest@node43*"
send "touch ping.txt\r"
expect "*guest@node43*"
send "ping -c 4 localhost > ping.txt\r"
send "exit\r"
expect eof
spawn scp guest@210.45.114.190:/home/guest/SA11011033/ping.txt ./
expect "*password*"
send "guest\r"
interact
linux 下expect的使用
最新推荐文章于 2024-10-30 13:57:55 发布