home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 December / PCO1296.ISO / filesbbs / os2 / whoami12.arj / WHOAMI.DOC < prev    next >
Encoding:
Text File  |  1996-06-23  |  6.6 KB  |  186 lines

  1. ********************************************
  2. * WHOAMI and PMWHOAMI for 32-bit OS/2 v1.2 *
  3. ********************************************
  4.  
  5. Here's another simplistic but useful-beyond-words program.
  6.  
  7. This program will tell you what your current domain name and IP address is.
  8. Granted, this won't do you ANY good unless you are connected to some sort of
  9. TCP/IP (Internet-type) network, by SLIP, PPP, or other means.
  10.  
  11. ***********
  12. * Usage : *
  13. ***********
  14. Usage is like so:
  15. whoami.exe [/K] [/HOST | /IP] [/EXE <runthis.exe> [cmdline1] [cmdline2] [...]]
  16.  
  17. It will return something along these lines:
  18.  
  19. foo.bar.com  (205.184.158.43)
  20.  
  21. or (if you specified whoami /IP)
  22.  
  23. 205.184.158.43
  24.  
  25. OR... (if you specified whoami /HOST)
  26.  
  27. foo.bar.com
  28.  
  29.  
  30. to stdout. ...So you can redirect this output elsewhere, for logging or use
  31. with a batch file or piped to another program. The possibilities are endless.
  32.  
  33. The optional "/K" command line sets the 'KEEP GOING' option, where, in case
  34. hostname information can't be retrieved, this program will continue to attempt
  35. to retrieve it until either it has, or you shut down the program.
  36.  
  37. What good is that? I'm glad you asked. Let's say you have a bunch of programs
  38. that you don't want to run until after you've connected, such as an email
  39. client. Do this: make a .cmd file...goppp.cmd, for example:
  40.  
  41. @echo off
  42. start /min myprogs.cmd
  43. SLIPPM
  44.  
  45.  
  46.  
  47. ...and myprogs.cmd...
  48.  
  49. whoami /k
  50. rem Nothing below this line runs until whoami returns (we're connected.)
  51.  
  52. etc...
  53.  
  54.  
  55.  
  56. Now, rather than call SLIPPM.EXE (the 'dial other internet providers' icon),
  57. call goppp.cmd.
  58.  
  59. ok, so it's complicated. :)  But besides that, it's still handy.
  60.  
  61. In case you missed it, specifying a /HOST on the command line will give you
  62. just the domain name (foo.bar.com...or whatever...the 'english' version of
  63. /IP), and /IP on the command line will return just the IP address (those
  64. four numbers, separated by periods.)
  65.  
  66. Also, there is a Presentation Manager application version of this included,
  67. called PMWHOAMI.EXE. This is prettier, but can't be redirected. (it ain't
  68. stdout...) Also, the trick I just illustrated above won't work as well with
  69. the PM version...although it accepts the "/K" command line in the same fashion,
  70. you'd have to exit the program before the batch file could continue. However,
  71. it is prettier to look at. (and /HOST or /IP work with it.) However, at this
  72. time /EXE doesn't work with it either. It can be done, I'd just have to
  73. re-write a portion of the code...and I'm just too lazy for that. :)
  74.  
  75.   therefore : "Next Version."  :)
  76.  
  77.  
  78. If, you have a program that needs a HOSTNAME environment variable set, and you
  79. are dynamically IPed (you don't know your hostname until each connection...)
  80. You can run your program through whoami.exe (This is only in the text version
  81. right now...)
  82.  
  83.  run : whoami.exe /host /exe myprog.exe cmdline1 cmdline2
  84.  
  85. ...will find out your hostname, and store it to the HOSTNAME environment
  86. variable, and then run myprog.exe with the command line "cmdline1 cmdline2"
  87.  
  88.          *** /EXE MUST BE THE LAST PARAMETER THAT YOU PASS WHOAMI. ***
  89.  
  90. I would specify "/k" and "/host" if you plan on using the "/exe" parameter.
  91. Most programs seem to expect HOSTNAME to be in that format, and without "/k"
  92. there's a possibility that HOSTNAME will be set to
  93. "Can't get hostname information." However, it's all optional.
  94.  
  95.  
  96. ***************
  97. * Neat trick: *
  98. ***************
  99. Oh, if the HOSTNAME variable is set to start with, you can lie to this program.
  100. if you
  101.  
  102.  SET HOSTNAME=voicenet.com
  103.  
  104. and then run whoami.exe, you'll get this:
  105. voicenet.com  (192.204.28.35)
  106.  
  107.  
  108. *****************
  109. * Compatibility *
  110. *****************
  111. WHOAMI Compatibility: This should work with OS/2 2.0 and higher with some
  112.                       sort of TCP/IP support.
  113.  
  114. ******************
  115. * Special Thanks *
  116. ******************
  117. Special Thanks to Nathan Zych, who got me off my lazy ass to write version 1.2.
  118.  
  119.  
  120. ***********************************************
  121. * "Hey! Why isn't this lousy thing working?!" *
  122. ***********************************************
  123. Troubleshooting:
  124.  
  125. --- WHOAMI.EXE bitches about not finding a DLL. What's the deal?
  126.  
  127. You need the EMX runtime to use the whoami programs. These shrink the size of
  128. the executables DRAMATICALLY. Plus, if you find yourself using a bunch of
  129. rinky-dink freeware utilities from the net like this one, you're eventually
  130. going to need it anyhow...The runtime can be found on OS/2 supporting BBSes
  131. globally, or via FTP from:
  132.  
  133. ftp://hobbes.nmsu.edu/os2/unix/emx09b/emxrt.zip
  134.  
  135. Follow the instructions for installation (I think you just unzip into your
  136. LIBPATH or something...) and then whoami will (probably) work.
  137.  
  138.  
  139. --- I can't run DOS or Presentation Manager programs from the /EXE option.
  140.  
  141. I'll fix this : next version. Feh.
  142.  
  143.  
  144. --- PMWHOAMI.EXE tells me to use the 'text version' whenever I specify "/EXE".
  145.  
  146. Again, next version. This one's just a matter of redesigning a bit of the
  147. source code. The workaround for now is to use WHOAMI.EXE (not PMWHOAMI), which
  148. will (for the most part) not complain about the /EXE option.
  149.  
  150.  
  151.  
  152. ***************
  153. * Source code *
  154. ***************
  155. Finally, the entire source code is included. I wrote this using EMX 0.9b, and
  156. BSD sockets (available from ftp://hobbes.nmsu.edu/os2/unix/emx09b/). However,
  157. I make no claim that this is 'Good' or 'clean' coding. I tried to, through a
  158. bunch of #ifdefs, put the VIO and PM versions of this program in the same
  159. source file. It's kinda messy, and there are a few kludges to accomodate both
  160. versions...regardless of this programming experimental disaster, it works.
  161. Feel free to use this source code in ANY way you see fit.
  162.  
  163. This program if freeware. If you get any use out of it, I would appreciate an
  164. email telling me you like it (mailto:warped42@ix.netcom.com), or an email
  165. telling me you hate it...or something.   :)
  166.  
  167. Enjoy.
  168.  
  169.                                  --Ryan C. Gordon (warped42@ix.netcom.com)
  170.  
  171.  
  172. --------------
  173. Version history:
  174.  v1.0 : It works. It works well.
  175.  v1.1 : Added /IP and /HOST command line options.
  176.         Would like to add an /EIP, /EHOST and /EALL (or something like that)
  177.            that'll SET this information in an Environment variable for the
  178.            current session. Anyone know what API can do this?
  179.         Shrunk code a BUNCH through various compiler options and .DEF file
  180.            instructions.
  181.  v1.2 : Didn't add /EIP, /EHOST, and /EALL, since the environment string
  182.         changes vanish when whoami terminates. However, added /EXE option to
  183.         run a program from whoami.exe which will have the new environment.
  184. --------------
  185.  
  186.