Reputation: 2656
I have this code
...
SERVERCONNECTION=$(wget --quiet -O - http://xx:[email protected]:10001/server | grep connections | awk '{print $36}')
Sometimes the url get inresponsive, then I want to kill wget process and set SERVERCONNECTIION variable to 0.
Upvotes: 1
Views: 2144
Reputation: 31
Another useless use of grep.
Use awk '/connections/ {print $36}'
instead, so that the whole line reads
wget --timeout=5 --quiet -O - http://xx:[email protected]:10001/server | awk '/connections/ {print $36}'
Upvotes: 3
Reputation: 2377
Set a timeout for the wget process with --timeout=seconds
, i.e.
SERVERCONNECTION=$(wget --timeout=5 --quiet -O - http://xx:[email protected]:10001/server | grep connections | awk '{print $36}')
Upvotes: 5