"Fossies" - the Fresh Open Source Software Archive

Member "freeha-1.0/service_scripts/port.monitor" (23 Nov 2006, 1431 Bytes) of package /linux/privat/old/freeha-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 
    4 #-------------------------------------------------------------------------#
    5 #  port.monitor                                                           #
    6 #  This script verifies that "something" is listening on the port named   #
    7 #   If this doesnt work for your OS, please submit a patch                #
    8 #                                                                         #
    9 # Usage:  port.monitor portnum [specific IP addr]                         #
   10 #                                                                         #
   11 # The default is to look for a 'globally bound port'                      #
   12 # If your process binds to a specific IP address. you MUST specify that   #
   13 # IP address, or this script will not detect it                           #
   14 #                                                                         #
   15 #  Standard UNIX status: returns 0 on good, non-0 on bad.                 #
   16 #                                                                         #
   17 #                                                                         #
   18 #-------------------------------------------------------------------------#
   19 
   20 
   21 PATH=$PATH:/usr/sbin:/sbin:/etc
   22 
   23 if [ "$1" = "" ] ; then
   24     echo "port.monitor: ERROR: no port number given"
   25     exit 1
   26 fi
   27 if [ "$2" = "" ] ; then
   28     IPADDR='*'
   29 else
   30     IPADDR="$2"
   31 fi
   32 
   33 netstat -an | fgrep $IPADDR".$1"|grep LISTEN >/dev/null
   34 
   35 if [ $? -eq 0 ] ; then
   36     exit 0 
   37 fi
   38 
   39 exit 1
   40