Browse Source

Add aliases for network

Emmanuel Bouthenot 8 years ago
parent
commit
430b946e4d
1 changed files with 15 additions and 0 deletions
  1. 15 0
      .zsh/config/10_alias.zsh

+ 15 - 0
.zsh/config/10_alias.zsh

@@ -97,6 +97,21 @@ fi
 alias scp_nosec="scp -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'"
 alias ssh_nosec="ssh -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'"
 
+# Network
+port-status() {
+    if [ $# != 2 ]; then
+        print "Usage: $0 [IP|HOSTNAME] [PORT|SERVICE]"
+    else
+        local host="${1}"
+        local service="${2}"
+        if nc -w 5 -z "${host}" "${service}" ; then
+            print "Port or sevice '${service}' is opened on '${host}'"
+        else
+            print "Port or sevice '${service}' is closed on '${host}'"
+        fi
+    fi
+}
+
 # OpenSSL
 for i in sha512 sha256 sha1 md5 ; do
     ssl-cert-$i() {