#!/usr/bin/expect
set timeout 30
spawn ssh 192.168.2.125
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "redhat\r" }
}
expect "]#"
send "df -h > /tmp/diskfile\r"
interact
set timeout 30
spawn ssh 192.168.2.125
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "redhat\r" }
}
expect "]#"
send "df -h > /tmp/diskfile\r"
interact
转载于:https://blog.51cto.com/angus717/891557