您的位置:首页 > 运维架构 > Shell

Shell结合Expect实现自动输入密码

2017-05-01 13:19 603 查看

  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 0 ]
then
echo "Download here: http://10.13.38.22/dir2_"$time".tar.gz" else
echo "Download Error!"
fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: