实现scp自动输入密码(判断yesno选项)

1、apt-get install expect

2、编写shell脚本test.sh

#!/usr/bin/expect -f
#!/bin/sh
set password 1
spawn scp root@192.168.1.93:/opt/ybs/bin/YSNY.pyc /opt/ybs/bin/
set timeout 10;
expect {
        yes/no {send yes\n;exp_continue};
        password: {send $password\n};
}
set timeout 10;
send exit\n;
expect eof;

posted @ 2014-08-07 16:55  夜半弯  阅读(1601)  评论(0编辑  收藏  举报