expect使用
#!/bin/bash /usr/bin/expect << EOF spawn ssh root@60.32.0.19 expect { "yes/no*" { send "yes\r"; exp_continue } "*assword:" { send "m2a1s2u30000049\r" } } expect "root@fort2:~#" send "df -lh\r" expect "root@fort2:~#" send "exit\r" EOF
#!/bin/bash /usr/bin/expect << EOF spawn ssh root@60.32.0.19 expect { "yes/no*" { send "yes\r"; exp_continue } "*assword:" { send "m2a1s2u30000049\r" } } expect "root@fort2:~#" send "df -lh\r" expect "root@fort2:~#" send "exit\r" EOF