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
;exp_continue};
password: {send $password
};
}
set timeout 10;
send exit
;
expect eof;