#!/usr/bin/expect
set timeout 5
spawn ssh root@192.168.3.8 "df -Th >>/root/disk.txt"
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "vision\r" }
}
spawn scp 192.168.3.8:/root/disk.txt /root/
expect "*password*"
send "vision\r"
expect eof
转载于:https://blog.51cto.com/victor2016/1915058