I have a bit of bash script like this:
echo "Number of Connections: "
Conns=$(netstat -an | grep -c ‘8800.*OK’)
echo "Done"
It appears to stop processing after netstat. The output I get is:
Number of Connections:
When I try it this way:
echo "Number of Connections: "
netstat -an | grep -c ‘8800.*OK’
echo "Done"
It proves the netstat is working but stopping the process, the output looks like this:
Number of Connections:
0
Is there a way to stop netstat from stopping the script from continuing?
Thanks
netstat -anactually finish, or is it hanging for some reason? Try runningnetstat -an | grep -c '8800.*OK'at the command line, and see if it finishes or hangs. Also, do you really have curly quotes around thegreppattern? They need to be plain quotes to work right.set -e(or something similar) in the script? If so, it'll exit ifgrepdoesn't find any matches (and hence exits with a failure status).