#!/bin/csh -f # nslookup_bare_ip_address # ----------------------------------------------------------------------------- # C shell script to do an nslookup of a hostname or a domain name and echo # only the IP address. Strips off the rest of the nslookup output. # ----------------------------------------------------------------------------- # 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 nslookup $1:q | grep -v "#53" | grep Address | sed -e "s/Address: //"