<pre name="code" class="sql">#!/bin/bash
passwd='1234567'
/usr/bin/expect<<EOF
set time 30
spawn scp 1.sh  root@192.168.32.65:/root
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect eof
EOF


/usr/bin/expect<<EOF
spawn ssh  root@192.168.32.65
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}


expect "*#"
send "who\r"
expect "*#"
send "date\r"
expect "*#"
send "exit\r"
interact
expect eof
EOF