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

来源:互联网 发布:linux输入法 编辑:程序博客网 时间:2024/05/18 16:15
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


原创粉丝点击