Shell结合Expect自动输入密码示例
1 #!/bin/bash 2 3 cd /data/live 4 5 /usr/bin/expect <<-EOF 6 spawn git clone "ssh://xxxxxxxxxxxx" 7 expect "*passphrase*" 8 send "passwordhere\n" 9 expect eof 10 EOF 11 12 time=`/bin/date "+%Y%m%d%H%M%S"` 13 cd dir1 && tar czf /data/www/dir2_$time.tar.gz dir2 14 cd .. && rm -rf dir1 15 if [ $? -eq 0 ] 16 then 17 echo "Download here: http://10.13.38.22/dir2_"$time".tar.gz" 18 else 19 echo "Download Error!" 20 fi
时间: 2024-09-30 03:01:52