From: Zachary Vance Date: Sun, 5 Feb 2017 10:45:51 +0000 (-0800) Subject: One port-checking system X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=1faabb9b5fb70e3a9c16f73464951d9450d378ff;p=za3k.git One port-checking system --- diff --git a/cgi-bin/check-port? b/cgi-bin/check-port? index 16f0bf6..ee15b60 100755 --- a/cgi-bin/check-port? +++ b/cgi-bin/check-port? @@ -1,7 +1,11 @@ -[ $# != 2 ] && echo "Wrong number of arguments to $(basename $0)" && exit 0 +[ $# != 2 ] && echo "Wrong number of arguments to $(basename $0)" && exit 1 HOST="$1" PORT="$2" -STATUS="$(nmap "$HOST" -p "$PORT" -oN - | grep "$PORT" | grep -v "#")" -echo "$STATUS" -echo "$STATUS" | grep -q "open" +if nmap "$HOST" -p "$PORT" -oN - 2>/dev/null | grep -q open +then + echo "Port $PORT open on $HOST" +else + echo "Port $PORT not open on $HOST" + exit 1 +fi diff --git a/cgi-bin/service.status.d/irc.za3k.com b/cgi-bin/service.status.d/irc.za3k.com index 594096d..c3aed97 100644 --- a/cgi-bin/service.status.d/irc.za3k.com +++ b/cgi-bin/service.status.d/irc.za3k.com @@ -1,7 +1 @@ -if nmap irc.za3k.com -p 6667 2>/dev/null | grep -q open -then - echo "Port 6667 open" -else - echo "Port 6667 not open" - exit 1 -fi +./check-port? irc.za3k.com 6667