实现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;

上一篇:linux的PS进程和作业管理(进程调度,杀死进程和进程故障-僵尸进程-内存泄漏)


下一篇:Backbone入门