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\r\n" }
expect "password:" { send "$password\r\n" }
expect eof
}
EOF
done
2.
#!/bin/bash
echo OK
/usr/bin/expect << EOF
spawn ssh [email protected]
expect "password:"
set timeout 300
send "123456\r"
expect "]#"
send "exit\r"
expect eof
EOF
时间: 2024-10-25 18:30:25