home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SATAN11.ZIP / PERL / HOSTNAME.PL < prev    next >
Perl Script  |  1995-04-11  |  561b  |  24 lines

  1. #
  2. # file: hostname.pl
  3. # usage: $hostname = &'hostname;
  4. #
  5. # purpose: get hostname -- try method until we get an answer 
  6. #    or return "Amnesiac!"
  7. #
  8.  
  9. package hostname;
  10.  
  11. sub main'hostname {
  12.     if (!defined $hostname) {
  13.     $hostname =  ( -x '/bin/hostname'     && `/bin/hostname` ) 
  14.           || ( -x '/usr/ucb/hostname' && `/usr/ucb/hostname` )
  15.           || ( -x '/bin/uname'        && `/bin/uname -n` )
  16.           || ( -x '/usr/bin/uuname'   && `/usr/bin/uuname -l`)
  17.           || 'Amnesiac! ';  # trailing space is for chop
  18.     chop $hostname;
  19.     }
  20.     $hostname;
  21. }
  22.  
  23. 1;
  24.