#
# Include Files
#
use strict;
use warnings;
#
# Variable Declarations and Initialization
#
my $char = '"';
my $cmd;
our $device = '';
#
# Main Script Body
#
#check if device name is supplied
if($#ARGV == 0)
{
$device = $ARGV[0]; # store device name in variable
# concatenate device name with fdisk command
$cmd = 'fdisk -c'.' '.$device.' < fdisk.input'; #######This works
system $cmd;
exit 0;
}
else {
print "Format Error:Usage- partition.pl \n";
print "Example: partition.pl ";
print $char; print "/dev/sdf"; print "$char\n";
exit -1; # displayed as 255
}
######
fdisk.input has these params:
n
p
1
1
+G
t
83
w
####
####
$cmd = 'fdisk -c'.' '.$device.' n p 1 1 +G t 83 w';
# this displays fdisk usage error
####
$cmd = 'fdisk -c'.' '.$device;
system $cmd;
system " n p 1 1 +G t 83 w";
## this however enters the fdisk prompt and waits for the above inputs !!