home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / DIR / WHICH20.ZIP / WHICH.DOC < prev    next >
Encoding:
Text File  |  1990-01-02  |  10.5 KB  |  256 lines

  1.  
  2.  
  3.                                  WHICH, v2.0
  4.                                 -------------
  5.                                 from TifaWARE
  6.  
  7.  
  8.  
  9.  
  10. What's New
  11. ----------
  12.  
  13.  
  14.      New to version 2.0 is a verbose reporting option; with it you see
  15. exactly which directories are being searched. Additionally, several of the
  16. main functions in WHICH have been rewritten, and AT&T's getopt() function
  17. is now used for a consistent method of option processing. Finally, memory
  18. problems at run-time should be a thing of the past as directory names no
  19. longer require additional memory allocation. 
  20.  
  21.      Version 1.2 of WHICH does not represent much of an improvement over
  22. the preceding release, at least from the user's viewpoint. Some of the code
  23. for displaying the on-line help message was improved, and error messages
  24. are formated in a slightly different fashion. Also, program names are not
  25. converted to uppercase if no match is found.
  26.  
  27.  
  28.  
  29.  
  30. Introduction
  31. ------------
  32.  
  33.  
  34.      With the increasing popularity and size of hard disks, keeping track
  35. of executable programs is becoming more and more difficult.  If you're like
  36. me, you probably have a few programs on your disk with the same filename,
  37. possibly even some in the same directory.  Which one will be run when you
  38. type the command's name at the DOS prompt?
  39.  
  40.      The answer, of course, depends on your current directory as well as
  41. the setting of the PATH environment variable.  When you type a command at
  42. the DOS prompt and press <ENTER>, DOS determines if the command is internal
  43. or external.  Internal commands - CLS, DIR, COPY, etc... - are implemented
  44. within DOS itself; external ones are disk files with an extension of COM,
  45. EXE, or BAT.  First, DOS compares your command against its list of internal
  46. ones.  If no match is found, DOS assumes the command is external and tries
  47. to find the program on disk.  It looks in the current directory for a file
  48. with the same filename as the command and an extension of COM, EXE, or BAT
  49. in _that_ order.  If DOS is still unsuccessful, it then continues to search
  50. sequentially through the directories specified by the environment variable
  51. PATH until a match is found.  Only if DOS runs out of directories to scan
  52. does it print the dreaded "Bad command or file name" message. 
  53.  
  54.      As the name suggests, WHICH searches your system for programs that
  55. MS-DOS is capable of running.  It is not a general file-search utility a la
  56. PKFIND or WHEREIS; rather, it scans only a few directories for executable
  57. programs or batch files.  But it can save a lot of frustration if any of
  58. your programs have the same names. 
  59.  
  60.  
  61.  
  62.  
  63. Usage
  64. -----
  65.  
  66.  
  67.      Running this program is straightforward.  Once you've placed WHICH.COM
  68. on your disk where DOS can find it (either in the current directory or one
  69. specified by PATH), you're ready to use it.  Type WHICH -? and you'll see a
  70. message similar to the following:
  71.  
  72.      TifaWARE WHICH, v2.0, Jan 02 1990 - scans path for executable programs.
  73.      Usage:  which [-options] prog(s)
  74.      
  75.      Options:
  76.        -a = find all possible matches
  77.        -v = verbose reporting
  78.        -? = provide this help message
  79.      
  80.      Prog(s) must not contain wildcards or drive/path/extension info.
  81.      
  82. [If you don't remember anything else from reading the documentation, at
  83. least remember how to display this help message.]
  84.  
  85.      To search for one or more files, simply add their filenames to the
  86. command line when you invoke WHICH.  [Note: Only "filenames" are accepted
  87. as arguments; i.e., that part of a file's name located between the drive
  88. and path specifiers on one hand and the extension on the other.  For the
  89. file named "C:\AUTOEXEC.BAT", the filename is "AUTOEXEC".] Suppose you want
  90. to determine which versions of GREP, WP, and DV will be executed by DOS. 
  91. Then you could simply type "which grep wp dv".  On my system, this produces
  92. the following output:
  93.  
  94.      C:\BIN\GREP.EXE
  95.      which: no matches for wp.
  96.      C:\USR\BIN\DV.BAT
  97.  
  98. Notice that when reporting matches, WHICH converts filenames to uppercase
  99. regardless of how they are specified on the commandline.  MS-DOS does not
  100. distinguish between upper- and lower-case letters in filenames; neither
  101. does WHICH.
  102.  
  103.      You can force WHICH to search all directories in the path by using the
  104. 'a' option. What good is this? For one, it's a way of locating extra copies
  105. of programs and freeing up vital disk space. You'd be surprised how many
  106. people keep two or three copies of COMMAND.COM, for example, on their hard
  107. disk! For another, this option can help determine why a particular program
  108. exhibits different behaviour depending on where you are when it's invoked.
  109. Rather than pulling out all your hair you might discover two distinct batch
  110. files with the same name but in different locations on your hard disk.
  111.  
  112.      The 'v' option is primarily designed for debugging purposes. It simply
  113. enables verbose reporting of WHICH's progress through each directory. With
  114. this option you can tell exactly which directories are being searched. As a
  115. bonus, you'll see if any tricks were used to name a directory (like hidden
  116. characters!) since each name should end with a backslash.
  117.  
  118.      When WHICH is successful, it writes a program's complete file name to
  119. standard output.  Using the DOS redirection characters '>' and '|', you
  120. could send this ouput to a disk file, printer, or even use it as input into
  121. another program. 
  122.  
  123.  
  124.  
  125.  
  126. If You Have Any Trouble
  127. -----------------------
  128.  
  129.  
  130.      WHICH will either report the full file names for the programs you
  131. specify on the command line or notify you of a problem.  Here are the error
  132. messages you might see and how you should deal with them:
  133.  
  134.      which: illegal option -- x.
  135.           - Type "WHICH -?" for a list of valid options. If your 
  136.             program's name starts with a '-', you can avoid
  137.             having WHICH treat the name as a set of options by
  138.             preceding it with another name. For instance, typing
  139.             WHICH AUTOEXEC -ODDNAME would search for the program 
  140.             -ODDNAME as desired.
  141.  
  142.      which: can't determine directories to search.
  143.           - WHICH can't figure out the default directory perhaps
  144.             because of trouble with the current drive.
  145.  
  146.      which: invalid filename -- c:progname.
  147.           - Look back at the definition of a filename. It must 
  148.             not contain any drive, path, or extension information 
  149.             *nor* wildcards.
  150.  
  151.      which: no matches for progname.
  152.           - Check the setting of PATH, the current directory, and 
  153.             the spelling of the program's name. Or perhaps the 
  154.             program simply doesn't exist on your machine.
  155.  
  156. These error messages are written to the standard error device.  In this
  157. way, they won't disappear down a pipe or into a file should you try to
  158. redirect WHICH's output. 
  159.  
  160.      Additionally, WHICH uses a return code to convey information about the
  161. success or failure of its searches.  Possible return values are:
  162.  
  163.      Code      Meaning
  164.      ----      -------
  165.      0         Matches were found for all program names
  166.      1         Help message was displayed
  167.      5         WHICH could not determine which directories to search
  168.      10        At least 1 program name could not be matched
  169.      20        At least 1 program name was an invalid filename.
  170.  
  171. You can test for these codes using the ERRORLEVEL variable in a batch file.
  172.  
  173.      Finally, it should be noted that WHICH limits processing to 25
  174. directories; it will simply ignore any others listed in your PATH. If this
  175. is a problem for you, you can either reorganize your hard disk or change
  176. the constant MAX_DIRS in the source and recompile. I strongly recommend
  177. the first course of action.
  178.  
  179.  
  180.  
  181.  
  182. Requirements
  183. ------------
  184.  
  185.  
  186.      TifaWARE WHICH runs on machines operating under MS-DOS v2.xx or later,
  187. and requires roughly 10K of memory.  It does not use BIOS calls, make
  188. direct writes to video RAM, or otherwise require machines to be
  189. "PC-compatible".  In fact, WHICH even runs properly on a DEC Rainbow!
  190.  
  191.      WHICH makes no attempt to work with any command aliasing utilities or
  192. path-extenders for the PC; eg, ALIAS, SEARCH, GLOBALS, ...  If you try to
  193. use it with one of the former, WHICH will probably report no matches; with
  194. one of the latter, probably a match in the current directory regardless of
  195. how PATH is set.
  196.  
  197.  
  198.  
  199.  
  200. Who Owns WHICH?
  201. ---------------
  202.  
  203.  
  204.      I am releasing this implementation of WHICH into the public domain. 
  205. Since my involvement with MS-DOS began in 1984, I've been a heavy user of
  206. public domain software (especially Kermit and a host of utilities for the
  207. DEC Rainbow).  Public domain software is a terrific idea.  For the most
  208. part, programs are useful and the source code instructive, all at no cost!
  209. With this small contribution to the public domain I hope to pay back, in
  210. some sense, my gratitude to those other programmers who have made my
  211. computing so much easier. 
  212.  
  213.      As a public domain program, WHICH carries no obligation on my part to
  214. support users or provide future upgrades.  I have tried to write clean code
  215. and believe it to be for the most part "bug-free".  Nevertheless, you must
  216. use this program ***AT YOUR OWN RISK***.  I strongly urge you to scan the
  217. source code yourself, make any desired changes, and recompile the program,
  218. if this is possible.  If you make this standard practice with newly
  219. acquired public domain software, you'll not only protect your system from
  220. worms and viruses but also get a better feel for exactly how each program
  221. works!
  222.  
  223.      As author of WHICH, I ask of you two things: First, if you distribute
  224. this program, please keep together my original source code, documentation,
  225. and executable.  This just makes it easier for others to use the software. 
  226. Second, let me hear what you think of WHICH.  You don't have to send any
  227. money, just comments and suggestions. 
  228.  
  229.  
  230.  
  231.  
  232. Kudos
  233. -----
  234.  
  235.  
  236.      The idea for WHICH came to me while reading _The UNIX Programming
  237. Environment_ by Kernighan & Pike.  The code itself was written using
  238. Borland's TURBO C, v2.0.  I've seen several implementations of WHICH
  239. already in the public domain, but I wanted to try out TURBO C's integrated
  240. development environment.  Not bad!
  241.  
  242.  
  243.  
  244.  
  245.  
  246.                           George A. Theall
  247.  
  248.                              TifaWARE
  249.                        506 South 41st St., #3M
  250.                       Philadelphia, PA.  19104
  251.                               U.S.A.
  252.  
  253.                           (215) 662-0558
  254.  
  255.               GTHEALL@PENNDRLS.UPENN.EDU (ARPA Internet)
  256.