0
嗨我一直在論壇上搜索,但我似乎無法得到這個權利。我正在嘗試創建一個腳本,詢問用戶正在搜索哪個進程,如果進程正在運行,則返回1。閱讀變量爲ps ax腳本
這工作:
#!/bin/bash
SERVICE='httpd'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running"
fi
我想要將它添加到腳本:
echo -e "please enter process name: \c"
read word
類似:
#!/bin/sh
echo -e "please enter process name: \c"
read input_variable
if ps ax | grep -v grep | grep $varname > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running"
fi
很感謝它得到了第5和第7行的「」 – nycjay01