expect是
#!/bin/bash
passwd='123456'
/usr/bin/expect <<EOF
set time 30
spawn ssh root@192.168.76.10
expect {
"*yes/no" { send "yes
"; exp_continue}
"*password:" {send "$passwd
"}
}
expect "*#"
send "cd /tmp
"
expect "*#"
send "echo 222 > 2.txt
"
expect "*#"
send "df -h
"
expect "*#"
send "free -m
"
expect "*#"
send "ps -ef | grep httpd
"
expect "*#"
send "quit
"
interact
expect eof
EOF