dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

isopen (408B)


      1 #!/bin/sh
      2 
      3 if [ -n "$1" ] && [ "$1" != "" ] && [ -n "$2" ] && [ "$2" != "" ]; then
      4 	case "$2" in
      5 	''|*[!0-9]*) echo "PORT is not a number" ;;
      6 	*)
      7 		case $((
      8 			($2 <= 0)       * 1 +
      9 			($2 > 65535)    * 2
     10 		)) in
     11 			(1) echo "PORT must be greater than 0" ;;
     12 			(2) echo "PORT must be lower than or equal to 65535" ;;
     13 			(0) nc -vzw 1 "$1" "$2" ;;
     14 		esac
     15 		;;
     16 	esac
     17 else
     18 	echo "usage: isopen ADDRESS PORT"
     19 fi