linux scp拷贝文件,跳过“yes/no”

scp_file.sh
#!/usr/bin/expect
if $argc!=2 {
send_user "Usage: expect scp_files.sh remote_ip remote_root_password.\n\n"
exit
}
set remote_ip [lindex $argv 0] 
set pwd  [lindex $argv 1]


set timeout 120;
spawn /usr/bin/scp /home/dbadmin/public.db root@$remote_ip:/home
set timeout 1
expect {
"*yes/no*" {send "yes\r";exp_continue}
}
expect "*assword*"
send "$pwd\r"
set timeout 100

expect eof


linux命令行下执行:

expect scp_files.sh 192.8.8.8 my_password


你可能感兴趣的:(linux scp拷贝文件,跳过“yes/no”)