1.ssh交互
#!/bin/bash passwd='123' usradd="172.168.74.138" /usr/bin/expect <<EOF spawn ssh root@$usradd expect { "yes/no" { send "yes ";exp_continue } "password:" { send "$passwd " } } expect "]#" send "ifconfig " send "exit " expect eof EOF
#!/bin/bash passwd='123' usradd="172.168.74.138" /usr/bin/expect <<EOF spawn ssh root@$usradd expect { "yes/no" { send "yes ";exp_continue } "password:" { send "$passwd " } } expect "]#" send "ifconfig " send "exit " expect eof EOF