
shell编程 if语句 那里错了啊
#!/bin/shID=$(ps-ef|grepnginx|awk'{print$3}'|head-1)echo"theisnginxstart/stopshell"sl...
#!/bin/sh
ID=$( ps -ef|grep nginx|awk '{print $3}'|head -1 )
echo "the is nginx start/stop shell"
sleep 1
echo "$ID"
sleep 1
if [ $ID -eq 1 ]
then
echo "nginx is start"
else
echo "nginx is stop"
fi
sleep 1
if [ $ID -eq 1 ]
then
echo "is start"
read -p "stop y or n :" Y
echo "the stop input:" $Y
elif [ $Y -eq 2 ]
then
/usr/local/nginx/sbin/nginx -s stop
echo " yes"
fi
sleep 4
if [ $ID -ne 1 ]
then
echo "is stop"
read -p "start y or n :" N
echo "the start $N"
elif [ $N -eq 2 ]
then
/usr/local/nginx/sbin/nginx
echo "yes"
fi
为什么执行不了命令 展开
ID=$( ps -ef|grep nginx|awk '{print $3}'|head -1 )
echo "the is nginx start/stop shell"
sleep 1
echo "$ID"
sleep 1
if [ $ID -eq 1 ]
then
echo "nginx is start"
else
echo "nginx is stop"
fi
sleep 1
if [ $ID -eq 1 ]
then
echo "is start"
read -p "stop y or n :" Y
echo "the stop input:" $Y
elif [ $Y -eq 2 ]
then
/usr/local/nginx/sbin/nginx -s stop
echo " yes"
fi
sleep 4
if [ $ID -ne 1 ]
then
echo "is stop"
read -p "start y or n :" N
echo "the start $N"
elif [ $N -eq 2 ]
then
/usr/local/nginx/sbin/nginx
echo "yes"
fi
为什么执行不了命令 展开
3个回答
展开全部
把你报错贴上来就能分析了。这个我直接拿去执行肯定是报错的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询