'How can I loop with all the nc -zv connections?
I am trying to write a script to monitor all the server ports. But I am able write to for only one connection at a time. How can I write it for all the connections?
nc -zv 192.1.2.3 8668
nc -zv 192.3.4.5 8668
nc -zv 192.4.5.6 8668
nc -zv 192.5.6.7 8668
Expected output should be like If any of the server port is unavailable, I should get a alert by saying "That particular server port is offline"
nc -zv 192.1.2.3 8668 >/dev/null 2>&1
online=$?
if [ $online -eq 0 ]; then
echo "Online"
else
echo "Offline"
fi
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|