<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
"; exp_continue }
"*password:" { send "$passwd
" }
}
expect eof
EOF
/usr/bin/expect<<EOF
spawn ssh root@192.168.32.65
expect {
"*yes/no" { send "yes
"; exp_continue }
"*password:" { send "$passwd
" }
}
expect "*#"
send "who
"
expect "*#"
send "date
"
expect "*#"
send "exit
"
interact
expect eof
EOF