ssh交互式登录脚本

#!/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

你可能感兴趣的:(交互式操作)