home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / dialip2.zip / which.cmd < prev   
OS/2 REXX Batch file  |  1997-09-09  |  1KB  |  42 lines

  1. /* program: which  (a freeby)
  2. ** written: Stan J. Towianski
  3. ** purpose: looks for the input filename in the directories in your 
  4. **          PATH variable and tells you where it found it.
  5. **          OR if you give a 2nd arg. it will use that environment variable to get the
  6. **          path to look thru instead of PATH.  LIBPATH would be a common example.
  7. **    date: Dec/1996
  8. */
  9.  
  10. parse arg fname fpath
  11.  
  12. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  13. call SysLoadFuncs
  14.  
  15. if ( fpath = '' ) then
  16.     fpath = 'PATH'
  17.  
  18. fpath = translate( fpath )
  19.  
  20. if ( fpath = 'LIBPATH' ) then
  21.     Do
  22.     dll_path = value( 'SYSTEM_INI', , 'OS2ENVIRONMENT' )
  23.     dll_drive = filespec( 'drive', dll_path )
  24.  
  25.     configpath = dll_drive||'\config.sys'
  26.     rc = stream( configpath, 'c', 'open' )
  27.     Do while ( lines( configpath ) > 0 )
  28.         tline = linein( configpath )
  29.         if ( left( tline, 7 ) = 'LIBPATH'  |  left( tline, 7 ) = 'libpath' ) then
  30.             Do
  31.             '@set' tline
  32.             leave
  33.             End
  34.     End
  35.     rc = stream( configpath, 'c', 'close' )
  36.     End
  37.  
  38. found_at = syssearchpath( fpath, fname )
  39. say found_at
  40. return found_at
  41.  
  42.