All pastes #163863 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-07 23:54 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