【发布时间】:2013-06-01 00:09:36
【问题描述】:
我有一个脚本来检查 url 的状态。我正在尝试从下面提到的 wget 命令输出中查找单词connected 并打印Running,如果找到则打印Not Running。如何修改我的 grep 以仅打印单词而没有 wget 命令的所有输出
#!/bin/ksh
STAT=`wget 'http://server:port/ABC_Service/app' | grep connected`
if [ -z "$STAT" ] ; then
echo "Running"
else
echo "Not Running"
fi
wget 命令的输出:
--2013-05-31 11:09:32-- http://server:port/ABC_Service/app
Resolving server... 10.109.136.31
Connecting to server|10.109.136.31|:port... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.
我的脚本所需的输出:
Running
【问题讨论】: