FDISK'ing via REXX 
Author Message
 FDISK'ing via REXX

All,

I am in the process of developing a script that will execute FDISK and
partition the hard drive into three partitions:  Bootmanager, C:primary,
D:logical.  The script works great on machines that do not utilize a system
partition, but fails on those that do require one (e.g. Compaq).  So far, I
have been unsuccessful at accounting for the existence of this additional
partition and preserving it.

The following is the procedure responsible for retaining the system partition
and removing all others.  I have modified it to run independently for the sake
of testing.

/* REXX */
input_file = 'A:\QRY_FDSK.DAT'
tmp_file = 'A:\TMP.DAT'
tmp_status = ' '
file_status = ' '
input_line = ' '
toNul = '> NUL'

'I:\OS2V30\DISK_1\FDISK /QUERY > A:\QRY_FDSK.DAT'
file_status = STREAM(input_file, 'C', 'CLOSE')     /* make sure file is closed
*/
file_status = STREAM(input_file, 'C', 'OPEN')      /* open the file */
DO WHILE LINES(input_file)
  line = LINEIN(input_file)
  line = TRANSLATE(line)                /* make it uppercase */
  IF POS( 'DRIVE', line ) <> 0          /* removing headings from DAT file */
        THEN line = ''
  CALL LINEOUT tmp_file, line           /* write the new lines to tmp.dat */
END

tmp_status = STREAM(tmp_file, 'C', 'CLOSE')     /* close the temp file */
file_status = STREAM(input_file, 'C', 'CLOSE')  /* close the query file */
'COPY A:\TMP.DAT A:\QRY_FDSK.DAT'               /* copy temp file to
input_file */
'DEL A:\TMP.DAT'

file_status = STREAM(input_file, 'C', 'OPEN READ')   /* open the query file
for reading */

DO WHILE file_status <> 0
     file_status = LINES(input_file)
     input_line = LINEIN(input_file)
     PARSE VALUE input_line WITH Drive Name Partition Vtype FStype Status
Start Size
     IF Partition == ':' THEN ITERATE        /* this is the system partition
*/
                DO
                      'I:\OS2V30\DISK_1\FDISK /DELETE /DISK:1 /NAME:' | | Name
                END
END  
file_status = STREAM(input_file, 'C', 'CLOSE')  /* close the file */
EXIT

/* End of script */

My input_file is similar to this:

Drive Name  Partition Vtype FStype Status   Start     Size

    1 ########     :     1    12      1          0      #
    1 ########     C:    1    16      1          #      ###
    1 ########     D:    2    0a      2        ###      ###

My tmp_file is similar to this:

    1 ########     :     1    12      1          0      #     /* need to keep
this */
    1 ########     C:    1    16      1          #      ###   /* need to
delete the next two */
    1 ########     D:    2    0a      2        ###      ###

When the script executes, it processes the loop, correctly identifies the Name
variable, then appends it to the FDISK command.  However, it does not remove
the partition.  Instead it returns an error message stating that the "Value is
0, a value of 1 is required, no operation was performed."  

Why does FDISK appear to recognize the Name argument but not execute?  When I
run FDISK from the command line using the same arguments, it performs
flawlessly.  Obviously, there is something wrong with my code, but I have no
idea what it is.

Any help is greatly appreciated.  




Thu, 26 Aug 1999 03:00:00 GMT  
 FDISK'ing via REXX


(Jonathan Alumbaugh)9 Mar 1997 19:31:35 GMT writes:
:>
:>All,
:>
:>I am in the process of developing a script that will execute FDISK and
:>partition the hard drive into three partitions:  Bootmanager, C:primary,
:>D:logical.  The script works great on machines that do not utilize a system
:>partition, but fails on those that do require one (e.g. Compaq).  So far, I
:>have been unsuccessful at accounting for the existence of this additional
:>partition and preserving it.

You should look for the FStype of the compaq systempartition and not
delete it.

[...]

:>     IF Partition == ':' THEN ITERATE        /* this is the system partition
:>*/

You assume that *only* System partions get no drive letter. What about a
second physical drive, which only has extended partitions?

[...]

:>
:>When the script executes, it processes the loop, correctly identifies the Name
:>variable, then appends it to the FDISK command.  However, it does not remove
:>the partition.  Instead it returns an error message stating that the "Value is
:>0, a value of 1 is required, no operation was performed."  
:>
:>Why does FDISK appear to recognize the Name argument but not execute?  When I
:>run FDISK from the command line using the same arguments, it performs
:>flawlessly.  Obviously, there is something wrong with my code, but I have no
:>idea what it is.

Try a TRACE ?I Statement
We put the Name parm in qotes:

'fdisk /delete '||"'"||'/name:'labl||"'"||' /disk:'idsknr

CU/2
--



Fri, 27 Aug 1999 03:00:00 GMT  
 FDISK'ing via REXX


Beythien)Mon, 10 Mar 1997 20:53:18 GMT writes:
:>
:>You should look for the FStype of the compaq systempartition and not
:>delete it.
:>:>     IF Partition == ':' THEN ITERATE        /* this is the system partition
:>:>*/
:>
:>You assume that *only* System partions get no drive letter. What about a
:>second physical drive, which only has extended partitions?
:>
Agreed, but fortunately for me, we have a company standard that must be
adhered to in order to qualify for support.  Two physical disks is not a
supported configuration (but you are perfectly correct nonetheless).  I had
considered this problem, but did not know if the FStype would always remain
the same across platforms.  I did some limited testing and discovered that the
system partitions on Compaq boxes was identified as FStype 12.  Will this
always be the case?  If so, I prefer your method.  

:>Try a TRACE ?I Statement
:>We put the Name parm in qotes:
:>
:>'fdisk /delete '||"'"||'/name:'labl||"'"||' /disk:'idsknr
:>
Thanks for the input.  I am rather new to REXX and had not considered using
TRACE.    

FWIW, I 'fixed' the script by omitting TRANSLATE.  For some reason, yet to be
determined, FDISK did not like the parameters passed to it after the
input_file had been converted to uppercase.  I removed that line and all was
well.  Granted, the code reeks of a rank amateur, but it works.

Thanks again.




Sat, 28 Aug 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. 'with'ing and 'use'ing

2. un-'upvar'ing/un-'global'ing variables

3. FTP'ing and FAX'ing from within C4b

4. segfault dup'ing string through C++ (via swig) module

5. OS/400 REXX - changing variables via API's

6. Accessing MMPM's convert image utility via rexx

7. 'make'ing ghc on darwin

8. 'call'ing a variable

9. Expect: Trouble 'expect'ing linefeeds

10. Ping'ing w/o plugins

11. C5EE GOLD - GPF'ing should read C55EE Gold

12. C5EE GOLD -W2K- GPF'ing with Large Dict - MSQL

 

 
Powered by phpBB® Forum Software