这是我的foobar.sh的代码:
!#/bin/bash
while [ 1 ]
do
pid=`ps -ef | grep "mylittleprogram" | grep -v grep | awk ' {print $2}'`
echo $pid
if [ "$pid"="" ]
then
echo "Process has ended lets get this show on the road..."
exit
else
echo "Process has not ended yet"
fi
sleep 6
done
我基本上运行一个infinate循环,一旦受监视的进程结束就会执行命令X但是当我的脚本循环时我最终收到以下消息:
./foobar.sh: line 7: [: missing `]'
Process has not ended yet
有没有办法让脚本接受零反馈将触发我的’Then’语句并执行命令X,因为它不喜欢当前的方法.