home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / HOSTNAME.ICN < prev    next >
Text File  |  1991-09-05  |  1KB  |  48 lines

  1. ############################################################################
  2. #
  3. #    Name:     hostname.icn
  4. #
  5. #    Title:     Produce host name
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Version: 1.1
  10. #
  11. #    Date:     June 1, 1991
  12. #
  13. ############################################################################
  14. #  
  15. #  This procedure determines the name of the current host.  It takes no
  16. #  arguments.  Aborts with an error message if the necessary commands
  17. #  are not found.  Geared specifically for UNIX machines.
  18. #
  19. ############################################################################
  20. #
  21. #  Requires: UNIX, pipes
  22. #
  23. ############################################################################
  24.  
  25. procedure hostname()
  26.  
  27.     static h_name
  28.     initial {
  29.     (find("UNIX",&features), find("pipes",&features)) |
  30.         stop("hostname:  works only under UNIX")
  31.     close(open(fname <- "/usr/bin/hostname"|"/bin/uuname"|"/bin/uname"))
  32.         fname := {
  33.         case \fname of {
  34.         "/usr/bin/hostname" :  "/usr/bin/hostname"
  35.         "/usr/bin/uuname"   :  "/usr/bin/uuname -l"
  36.         "/bin/uname"        :  "/bin/uname -n"
  37.             } | "/usr/bin/uuname -l"
  38.     }
  39.     get_name := open(fname, "pr") |
  40.         stop("hostname:  can't find hostname/uuname/uname commands")
  41.         h_name := !get_name
  42.         close(get_name)
  43.     }
  44.  
  45.     return h_name
  46.  
  47. end
  48.