#!/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
本文转自chenzudao51CTO博客,原文链接:http://blog.51cto.com/victor2016/1915058 ,如需转载请自行联系原作者