Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
451 B

  1. # From: [email protected] (Aaron Sherman)
  2. sub hostname
  3. {
  4. local(*P,@tmp,$hostname,$_);
  5. if (open(P,"hostname 2>&1 |") && (@tmp = <P>) && close(P))
  6. {
  7. chop($hostname = $tmp[$#tmp]);
  8. }
  9. elsif (open(P,"uname -n 2>&1 |") && (@tmp = <P>) && close(P))
  10. {
  11. chop($hostname = $tmp[$#tmp]);
  12. }
  13. else
  14. {
  15. die "$0: Cannot get hostname from 'hostname' or 'uname -n'\n";
  16. }
  17. @tmp = ();
  18. close P; # Just in case we failed in an odd spot....
  19. $hostname;
  20. }
  21. 1;