天天看点

expect远程获取服务器性能数据

#!/usr/bin/expect

set timeout 5

spawn ssh [email protected] "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 ,如需转载请自行联系原作者

继续阅读