1.
#!/bin/bash
password="iiecas123"
dest_dir="/vds/conf"
for i in `cat $1`
do
/usr/bin/expect << EOF
spawn scp ubase.dat $i:/vds/conf/ubase.dat
set timeout 60
expect {
expect "(yes/no)?" { send "yes " }
expect "password:" { send "$password " }
expect eof
}
EOF
done
2.
#!/bin/bash
echo OK
/usr/bin/expect << EOF
spawn ssh root@192.168.0.105
expect "password:"
set timeout 300
send "123456
"
expect "]#"
send "exit
"
expect eof
EOF