1、apt-get install expect
2、編寫shell腳本test.sh
#!/usr/bin/expect -f
#!/bin/sh
set password 1
spawn scp [email protected]:/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;
轉載于:https://www.cnblogs.com/wangzhigang/p/3897588.html