最近刚学会的scp自动输入密码。
#!/bin/bash
set -x
TIME=`date +%Y%m%d%H%M%S`
SOURCE=‘/home/cqq/project‘
PASSWD=‘123‘
tar zcvf ${TIME}.tar.gz $SOURCE >>/dev/null 2>&1
expect -c "
spawn scp -r [email protected]:/home/cqq/project/src/ /home/test/
expect {
\"*assword\" {set timeout 300; send \"$PASSWD\r\";}
\"yes/no\" {send \"yes\r\"; exp_continue;}
}
expect eof"
#startall && echo "update ok"
时间: 2024-10-10 01:11:48