home *** CD-ROM | disk | FTP | other *** search
/ IBM Presents OS/2 Software Hits 1995 / OS-2_SW_HITS_2ND_EDITION_1995.ISO / i17 / pmx20c1.exe / PMXC1.ZIP / BIN / erasePCF.CMD < prev    next >
OS/2 REXX Batch file  |  1994-10-21  |  4KB  |  115 lines

  1. /*
  2.  * erasepcf.cmd - This is a utility REXX exec that erases the miscpcf and
  3.  * 75dpipcf PMX font directories.  Those directories are backup directories
  4.  * created the first time the PMX CSD containing native PM fonts is installed.
  5.  * This version deletes ONLY the directories explicitly created by the install code.
  6.  * This version checks that XFILES environment variable has been
  7.  * set up properly and both TCPBASE and TCPPMX have already been installed.
  8.  */
  9. 'ECHO OFF'
  10. XFILES = envvarcheck('XFILES')
  11. ETC = envvarcheck('ETC')
  12. prompt = 1
  13. arg arglist
  14. do forever
  15.     parse var arglist nextarg arglist
  16.     select
  17.     when nextarg = '-Y' then do
  18.         prompt = 0
  19.         end
  20.     when nextarg = '-?' then do
  21.         say "The following command line parms are supported."
  22.         say "-y  Delete the MISCPCF and/or 75DPIPCF directories without prompting."
  23.         exit 1
  24.         end
  25.     when nextarg = "" then
  26.         leave
  27.     otherwise
  28.         say "The following command line parms are supported."
  29.         say "-y  Delete the MISCPCF and/or 75DPIPCF directories without prompting."
  30.         exit 1
  31.     end /* select */
  32. end
  33.  
  34. X11PATH=filespec("path",XFILES)
  35. if substr(X11PATH, length(X11PATH), 1) = '\' then
  36.     X11PATH = substr(X11PATH, 1, length(X11PATH) - 1)
  37. X11BASE=filespec("drive",XFILES)||X11PATH
  38. /*
  39.     Assume X11BASE and BASE are the same for now. Eventually we may want to
  40.     allow them to be different.  I.e. look down the PATH variable for
  41.     the BIN files, the LIBPATH for the DLLs, and so on.
  42.     Better yet, prompt the user for an optional change and then check to find
  43.     the files that we should update.
  44. */
  45. BASE = X11BASE
  46. /* Must CD after direxist, as that proc leaves the dir arg current, if it
  47.  * exists.  That causes failures with RENAME and RD commands.
  48.  */
  49. if (direxist(X11BASE'\X11\MISCPCF')) then do
  50.    'CD' X11BASE
  51.    if prompt then 
  52.       'ERASE' X11BASE'\X11\MISCPCF\*.*'
  53.    else
  54.       'ERASE /N' X11BASE'\X11\MISCPCF\*.*'
  55.    'RD' X11BASE'\X11\MISCPCF'
  56.    if rc \= 0 then
  57.       call bailout("RD" X11BASE'\X11\MISCPCF')
  58.    end
  59. if (direxist(X11BASE'\X11\75DPIPCF')) then do
  60.    'CD' X11BASE
  61.    if prompt then
  62.       'ERASE' X11BASE'\X11\75DPIPCF\*.*'
  63.    else
  64.       'ERASE /N' X11BASE'\X11\75DPIPCF\*.*'
  65.    'RD' X11BASE'\X11\75DPIPCF'
  66.    if rc \= 0 then
  67.       call bailout("RD" X11BASE'\X11\75DPIPCF')
  68.    end
  69. return
  70.  
  71. envvarcheck: procedure
  72. arg envvar
  73. ENV = 'OS2ENVIRONMENT'
  74. retvar = VALUE(envvar,,ENV)
  75. if retvar = '' then
  76.     do
  77.     call beep 524,200
  78.     call beep 440,250
  79.     say ""
  80.     say "WARNING!"
  81.     say "You do NOT have the environment variable" envvar "defined!"
  82.     say "You already should have installed the OS/2 TCP/IP 2.0 base"
  83.     say "or its equivalent, and you already should have installed"
  84.     say "the X Window System option.  This update package only provides"
  85.     say "changes and additions to the already installed product."
  86.     say "Installation will not continue!"
  87.     say ""
  88.     exit 1
  89.     end
  90. return retvar
  91.  
  92. fileexists: procedure
  93. arg file
  94. progname = STREAM(file, 'C', 'QUERY EXISTS')
  95. return progname \= ''
  96.  
  97. direxist: procedure
  98. arg dir
  99. curdir = directory()
  100. newdir = directory(dir)
  101. call directory(curdir)
  102. return newdir \= ''
  103.  
  104. bailout: procedure
  105. arg arglist
  106. parse var arglist operation dir
  107. /* This proc is called to report a failure of 'operation' */
  108. /* performed with 'dir' as its parameter. */
  109. /* Write the message, if not CID, pause.  Then exit */
  110. say operation "FAILURE on directory" dir
  111. say "Ensure no other process is using the directory."
  112. say "ABORTING."
  113. pause
  114. exit 1
  115.