Cover V09, I04
Article
Listing 1
Listing 2
Listing 3

apr2000.tar


Listing 3: Redefine cylinders

use Expect;

my $Fdisk = Expect->spawn("/sbin/fdisk /dev/hda");

## Redo the cylinders

&Sub1 ($Fdisk,"x\n",":");

&Sub1 ($Fdisk,"h\n",":");
&Sub1 ($Fdisk,"255\n",":");
&Sub1 ($Fdisk,"s\n",":");
&Sub1 ($Fdisk,"63\n",":");
&Sub1 ($Fdisk,"c\n",":");
&Sub1 ($Fdisk,"$Cylinders\n",":"); 
&Sub1 ($Fdisk,"r\n",":");

print $Fdisk "w\n"; $Fdisk->expect(30,"Command (m for help):");

sub Sub1
{
my ($Fdisk,$Command,$Match) = @_;
print $Fdisk $Command;
$Fdisk->expect(3,"$Match");
my $Temp = $Fdisk->exp_before();
print "$Temp\n";
$Fdisk->clear_accum();
}