Shell结合Expect自动输入密码示例
#!/bin/bash cd /data/live /usr/bin/expect <<-EOF
spawn git clone "ssh://xxxxxxxxxxxx"
expect "*passphrase*"
send "passwordhere\n"
expect eof
EOF time=`/bin/date "+%Y%m%d%H%M%S"`
cd dir1 && tar czf /data/www/dir2_$time.tar.gz dir2
cd .. && rm -rf dir1
if [ $? -eq ]
then
echo "Download here: http://10.13.38.22/dir2_"$time".tar.gz"
else
echo "Download Error!"
fi