home *** CD-ROM | disk | FTP | other *** search
/ IBM CD Showcase / OS2_CD_ROM.iso / smce0001 / sware / install.cmd < prev    next >
Encoding:
Text File  |  1994-01-29  |  3.6 KB  |  113 lines

  1. /*
  2.  * INSTALL.CMD
  3.  * 
  4.  * This handy little program will take as input a program to execute and a
  5.  * drive and directory from whence to execute it.  It will then ask the user
  6.  * if that is the directory of choice, and, if it is not, get a valid path
  7.  * from said user.  If the directory does not exist it is created (after
  8.  * asking, of course).  The current directory is changed then the specified
  9.  * program (assumed to be in the same directory as this program, or including
  10.  * a path from this directory) is executed.  When the program returns the
  11.  * current directory is restored to the original directory.
  12.  *
  13.  * The program takes three parameters:  the program to execute followed by the
  14.  * directory to execute it in and the "name" of the program.  For example:
  15.  *
  16.  *   INSTALL UTILITY C:\MYPROG\UTILITY /My very own utility program/
  17.  *           ------- -----------------  ---------------------------
  18.  * Program name ^            ^                       ^
  19.  *       Execution Directory |                       |
  20.  *                               name of the program |
  21.  *
  22.  * For this time 'round no error checking is done.  It is assumed the input
  23.  * parameters are golden.
  24.  *
  25.  *  NOTE: for this application I assumed the program being run is a self-
  26.  *  extracting ZIP file, and hard-coded stuff that relies on that.
  27.  */
  28.  
  29. Trace off
  30. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  31. Call SysLoadFuncs
  32.  
  33. Parse arg prog dir '/' title '/' .
  34.  
  35. /* Ask the user if we should use the specified directory. */
  36. CLS
  37. target = ''
  38. overwrite = 'false'
  39. Do While target = ''
  40.   Say 'Specify the directory you want ' || title || ' to be installed in'
  41.   Say '  (the default directory is ' || dir || ').'
  42.   Say '  Type QUIT to quit this installation.'
  43.   Pull target
  44.   If target = 'QUIT' | target = 'Q' Then
  45.     exit(0)
  46.  
  47.   If target = '' Then
  48.     target = dir
  49.  
  50.   /* Check for the existence of this directory */
  51.   CALL SysFileTree target, 'list', 'DO'
  52.   If list.0 = 0 Then
  53.     Do
  54.       Say 'The directory ' || target || ' does not exist.'
  55.       Say 'Would you like to create it (Y/N)?'
  56.       Pull ans
  57.       If ans = 'Y' Then
  58.         Do
  59.           rc = SysMkDir( target )
  60.           If rc \= 0 Then
  61.             Do
  62.               Say 'ERROR: Could not create directory ' || target || '.'
  63.               Say '       Make sure the drive and path to it exists.'
  64.               dir = target
  65.               target = ''
  66.               Iterate
  67.             End
  68.           Else
  69.               Say 'Directory ' || target || ' created.'
  70.         End
  71.       Else
  72.         Do
  73.           If ans \= 'N' Then
  74.             Say "I'll presume that means NO."
  75.           Say ''
  76.           target = ''
  77.           Iterate
  78.         End
  79.     End
  80.  
  81.   /* Check to see if the directory is empty */
  82.   CALL SysFileTree target || '\*.*', 'list', 'FO'
  83.   If list.0 \= 0 Then
  84.     Do
  85.       Say 'The directory ' || target || ' is not empty.'
  86.       Say 'Do you want to overwrite the files currently there (Y/N)?'
  87.       Pull ans
  88.       If ans = 'Y' Then
  89.         overwrite = 'true'
  90.       Else
  91.         Do
  92.           If ans \= 'N' Then
  93.             Say "I'll presume that means NO."
  94.           Say ''
  95.           target = ''
  96.           Iterate
  97.         End
  98.      End
  99. End
  100.  
  101. /* If we got this far we must have a valid directory */
  102. x = SetLocal()        /* Save the current directory */
  103. currdir = Directory()
  104. x = Directory( target ) /* Move to the new directory */
  105.  
  106. /* NOTE!!!!!!!!!!!!!!!!!  hardcoded ZIP stuff!!!!!!!!!!!!! */
  107. If overwrite = 'true' Then
  108.   '@' || currdir || '\' || prog || ' -d -o'
  109. Else
  110.   '@' || currdir || '\' || prog || ' -d'
  111.  
  112. x = EndLocal()
  113.