Paul.G wrote:
The example below is just a test, I need to be able to insert multiple values
into a command, those values can be either 1, 2 or upto 5.
Below is closer to the working example, but I will read that document and to
help make a final decision.
# Check Free PV's
operation_CHECKFREEPVS();
$NEWMIRROR = $MIRROR + $numPV;
if ($numPV ne 0&& $MIRROR le 5) {
You are using string comparisons on numerical values which may not work
out the way you intended:
$ perl -le'
for my $MIRROR ( 0, 1, 4, 5, 6, 10, 4000 ) {
print "$MIRROR le 5 is ", $MIRROR le 5 ? "TRUE" : "FALSE";
}
'
0 le 5 is TRUE
1 le 5 is TRUE
4 le 5 is TRUE
5 le 5 is TRUE
6 le 5 is FALSE
10 le 5 is TRUE
4000 le 5 is TRUE
# lvextend
print "$numPV $NEWMIRROR $MIRROR\n";
switch ($numPV) {
case 1 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv
$FreePV[0]"); }
case 2 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0]
$FreePV[1]"); }
case 3 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0]
$FreePV[1] $FreePV[2]"); }
case 4 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0]
$FreePV[1] $FreePV[2] $FreePV[3]"); }
case 5 { run("/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv $FreePV[0]
$FreePV[1] $FreePV[2] $FreePV[3] $FreePV[4]");
}
You could do that like this:
if ( @FreePV && @FreePV <= 5 ) {
run( "/usr/sbin/lvextend -m $NEWMIRROR -s $sourcelv @FreePV" );
}
}
# lvsync
run("/usr/sbin/lvsync -T $sourcelv");
logprint "Successful $NEWMIRROR mirrors \t\t synced";
}
else {
cleanexit (10, "FAIL \t\t No Free PV's Available");
}
return 0;
}
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/