版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27232757/article/details/77235613
该脚本的源码是为了实现从远程的服务器上面拉文件到本机。
主要是为了实现自动输入密码的功能。
#!/bin/bash
shellPath=$(cd "$(dirname "$0")"; pwd)
pid=0
function check_process_exist(){
ps_out=`ps -ef | grep taskmanager | grep -v 'grep'`
result=$(echo $ps_out | grep $1)
if [[ "$result" == "" ]]; then
return 0
else
return 1
fi
}
/usr/bin/expect <<-EOF
spawn scp $1@$2:$3 "$shellPath/$4"
expect {
"yes/no" { send "yes\r";exp_continue }
"password" { send "$5\r" }
}
expect eof
exit 0
EOF
tar -zxvf $4
python modifyConfig.py $6
cd taskmanager
chmod +x proServer.sh
./proServer.sh start
pid=$(cat pid)
echo "waiting"
while true
do
check_process_exist $pid
if [ $? -eq 0 ]; then
echo "The process has stoped!"
exit 1
fi
sleep 1
done