[TriLUG] was more uselessinfo/commentary, now more percise perl question.
John F Davis
johndavi at us.ibm.com
Thu Mar 21 14:22:20 EST 2002
Hello
Ok, this sucks, but I need your help again with this problem.
# partition the disk.
open(SFDISK, "|/sbin/sfdisk $drive << EOF") or die "Oops! $!";
$cylCnt=$cyls/$numberOfPartitions;
$bCyl=0;
$eCyl=$cylCnt;
for ($i = 0; $i < $numberOfPartitions; $i++) {
$driveKey = $drive . (eval $i + 1);
if ($eCyl == $cylCnt) {
# print "hit the wrinkle.\n";
$cylCnt--;
}
print SFDISK "$bCyl, $eCyl, $partHash{$driveKey}, -";
print SFDISK "\n";
# similar neat way: print $partHash{qq{$drive$i}};
$bCyl = $eCyl;
$eCyl = $eCyl + $cylCnt;
}
#print SFDISK "\n";
print SFDISK "EOF\n";
close SFDISK;
# old bash way:
# sfdisk $minidiskdev << EOF
# 0,174,6,-
# 174,174,83,*
# 348,173,83,-
# EOF
This script is supposed to do what's in the above bash script. However, it
acts like its doing this:
sfdisk /dev/hde << EOF
EOF.
(You can try this with your existing harddisk using sfdisk -n so it won't
actually
modify your partition table. You have been warned.)
I played games with writing the "\n" and not. It doesn't seem to matter.
Either way
it doesn't work. man perllibc
Any clues?
Andrew Perrin <andrew_perrin at unc.edu>@trilug.org on 03/21/2002 12:07:02 PM
Please respond to trilug at trilug.org
Sent by: trilug-admin at trilug.org
To: trilug at trilug.org
cc:
Subject: Re: was [TriLUG] perl programming question. now more
uselessinfo/commentary
Fair 'nuff, although the shell-script version doesn't handle either.
ap
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
On Thu, 21 Mar 2002, Robert Wagoner wrote:
> Andy,
>
> Small nit - to avoid possible problems when writing into a pipeline,
> you should check the return status from the close() as well as the
> open(), and you also need to handle a SIGPIPE if it occurs.
> --
> Robert (top-posting due to brain-damaged mailer)
>
>
> >>> andrew_perrin at unc.edu 3/21/02 11:14 AM >>>
> There are several ways to do this; I would probably do something like
> the
> following:
>
> open(SFDISK, "|/path/to/sfdisk /dev/hde") or die "Oops! $!";
> print SFDISK <<EOF;
> 0,174,6,-
> 174,174,83, *
> 348,173,83, -
> EOF
> close SFDISK;
>
> Best,
> Andy (hoping he's right this time....)
>
> _______________________________________________
> TriLUG mailing list
> http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ:
> http://www.trilug.org/~lovelace/faq/TriLUG-faq.html
>
_______________________________________________
TriLUG mailing list
http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ:
http://www.trilug.org/~lovelace/faq/TriLUG-faq.html
More information about the TriLUG
mailing list