All pastes #163880 Raw Edit

akill

public text v1 · immutable
#163880 ·published 2006-09-08 00:30 UTC
rendered paste body
#!/usr/local/bin/bash
function checkport {
  echo -n "what port would you like to check?: "
  read PORT
  if [ "`sockstat -4 | awk '{print $6}' | tr ":" " " | awk '{print \" \" $2 \" \"}' | grep \" ${PORT} \"`" ]; then
          echo "that port IS in use.";
     else
          echo "that port is NOT in use";
  fi
}


while [ "1" ]; do
  echo -n "would you like to check for an open port? [y/n]: "
  read ANSWER
  case ${ANSWER} in
    y | Y)
       checkport;;
    n | N)
       echo "quitting"
       exit 0;;
  esac

done