#!/bin/csh -f # nslookup_beep # ----------------------------------------------------------------------------- # C shell script to monitor the IP address of a hostname or a domain name # and beep each time it changes, showing the new value. # ----------------------------------------------------------------------------- # Usage: See Usage section below or run with -h or --help to see usage. # Assumptions: # Effects: # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ----------------------------------------------------------------------------- # Collect command line options while ($#argv > 0) if ("$1:q" == "-h" || "$1:q" == "--help") then echo "Usage: $0:t host_or_domain_name" exit 1 else if ("$1" != "-" && "-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0 --help exit 1 else # Not a recognized option. Assume it's the first parameter break endif end # Collect command line arguments if ($#argv > 1) then echo "Error: Too many arguments" $0:t --help exit 1 else if ($#argv < 1) then echo "Error: Must specify a host or domain name" $0:t --help exit 1 endif set ip_address = "" while ( 1 == 1 ) set old_ip_address = "$ip_address" set ip_address = "`nslookup_bare_ip_address $1:q`" if ("$ip_address" != "$old_ip_address") then beep "`date` $ip_address" endif sleep 1 end