home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / HPFSBACK.ZIP / HPFSBACK.CMD
OS/2 REXX Batch file  |  1992-06-02  |  3KB  |  98 lines

  1. /* HPFSBAK.CMD   Backs up HPFS Volume to a FAT volume using ZOO.EXE and 
  2. EABACKUP.EXE.
  3.    Both files must be in your path (get these from any BBS ).
  4.    I created this for those of us who don't have  a way to backup our HPFS 
  5. drives (because our tape drive
  6.    manufacturers don't support OS/2 and HPFS).  You can then use your tape 
  7. drive software under DOS to
  8.    backup the large file created on your FAT drive.  This file should reside 
  9. on your HPFS volume */
  10.    
  11. /*
  12.           Useage: HPFSBAK s: d: filename
  13.            Where: HPFSBAK is this REXX file.
  14.            s: is your HPFS source drive
  15.            d: is a FAT drive with space free (lots!)
  16.            filename is the name to which the .ZOO extension will be added 
  17. */
  18. ARG source  dest  d_path
  19. argtester(source,'source drive',dest,'destination drive',d_path,'filename')
  20.  
  21. argtester:    /* Check for valid arguements and say what's wrong if they're 
  22. not */
  23. Return_Code = 0  /* Start with everything set to normal */
  24. DO i = 1 TO 5 BY 2 
  25.     IF ARG(i) = " " 
  26.     THEN DO
  27.  SAY "You must supply a " || arg(i + 1)
  28.  Return_Code = 1   /* Something's wrong with the syntax or options */
  29.     END
  30. END
  31.  
  32.  /* If arguements are valid execute EABACKUP.EXE to backup extended 
  33. attributes and store  them on the root of the HPFS volume.  Build file tree 
  34. by executing TREE.EXE on HPFS drive  and send the output to a temporary file 
  35. (Tree.File).  Read Tree.File and extract only the paths.   Fix the paths that 
  36. have spaces in them and then execute ZOO.EXE instructing it to store all 
  37. files  in the path.  Repeat this process for all paths, and append to the 
  38. .ZOO file.  */
  39.      
  40. main:
  41. IF Return_Code = 0 
  42. THEN DO
  43.  ADDRESS CMD eabackup source source '/s'
  44.  ADDRESS CMD 'TREE > Tree.File'
  45.  DO WHILE LINES(Tree.File)
  46.       thisline = LINEIN(Tree.File,,1)
  47.       IF POS('Path: ',thisline) = 1
  48.           THEN CALL out_file
  49.       ELSE;
  50.            NOP
  51.  END
  52.  CALL end_it
  53.  
  54. out_file:
  55.  newstring = SUBWORD(thisline,2)
  56.  newstring = source||newstring||'\*'
  57.  numspaces =(WORDS(newstring)-1)
  58.  num_questions = numspaces
  59.  IF numspaces \= 0
  60.       THEN
  61.       CALL fix_string
  62.  ELSE
  63.  NOP
  64.  ADDRESS CMD 'zoo ah '||dest||'\'||d_path||'.zoo' newstring
  65.  RETURN
  66.  
  67. fix_string: /* If there are spaces in the path, replace each with 3 question 
  68. marks (a character that will not  appear in legal filenames), then change 
  69. these to a quoted space which ZOO.EXE can handle */
  70.  
  71. DO WHILE numspaces >> 0
  72.  numspaces = numspaces -1
  73.  space_test = POS(' ',newstring)
  74.  newstring = DELSTR(newstring,space_test,1)
  75.  newstring = INSERT(???,newstring,space_test-1,)
  76. END
  77.  
  78. DO WHILE num_questions >> 0
  79.  num_questions = num_questions -1
  80.  space_test = POS('???',newstring)
  81.  newstring = OVERLAY('" "',newstring,space_test)
  82. END
  83. RETURN
  84.  
  85. END
  86. IF Return_Code <> 0  /* If something's wrong with the arguements, display 
  87. lines 8 to end of comment */
  88. THEN DO
  89.  SAY ; SAY ;
  90.  DO LINE = 8 WHILE SUBSTR(Sourceline(line),1,2)  <> '*/'
  91.  SAY Sourceline(line)
  92.  END
  93. END
  94. EXIT 1
  95.  
  96. end_it:
  97. EXIT 1
  98.