version 1.4, 2003/08/12 10:40:44
|
version 1.5, 2003/08/12 10:55:42
|
Line 50
|
Line 50
|
# not the IP address of the host. |
# not the IP address of the host. |
# |
# |
# $Log$ |
# $Log$ |
|
# Revision 1.5 2003/08/12 10:55:42 foxr |
|
# Complete command line parsing (tested) |
|
# |
# Revision 1.4 2003/08/12 10:40:44 foxr |
# Revision 1.4 2003/08/12 10:40:44 foxr |
# Get switch parsing right. |
# Get switch parsing right. |
# |
# |
Line 111 USAGE
|
Line 114 USAGE
|
sub ParseArgs { |
sub ParseArgs { |
my $pushing = ''; |
my $pushing = ''; |
my $reiniting = ''; |
my $reiniting = ''; |
|
|
if(!GetOptions('push=s' => \$pushing, |
if(!GetOptions('push=s' => \$pushing, |
'reinit=s' => \$reinitting)) { |
'reinit=s' => \$reinitting)) { |
return (); |
return (); |
Line 118 sub ParseArgs {
|
Line 122 sub ParseArgs {
|
|
|
# Require exactly one of --push and --reinit |
# Require exactly one of --push and --reinit |
|
|
my $command = ''; |
my $command = ''; |
my $commandarg = ''; |
my $commandarg = ''; |
|
my $paramcount = @ARGV; # Number of additional arguments. |
|
|
|
|
if($pushing ne '') { |
if($pushing ne '') { |
|
|
|
# --push takes in addition a table, and a host: |
|
# |
|
if($paramcount != 2) { |
|
print "Bad count $paramcount\n"; |
|
return (); # Invalid parameter count. |
|
} |
if($command ne '') { |
if($command ne '') { |
return (); |
return (); |
} else { |
} else { |
|
|
$command = 'push'; |
$command = 'push'; |
$commandarg = $pushing; |
$commandarg = $pushing; |
} |
} |
} |
} |
|
|
if ($reinitting ne '') { |
if ($reinitting ne '') { |
|
|
|
# --reinit takes in addition just a host name |
|
|
|
if($paramcount != 1) { |
|
print "Bad count $paramcount\n"; |
|
return (); |
|
} |
if($command ne '') { |
if($command ne '') { |
return (); |
return (); |
} else { |
} else { |
Line 137 sub ParseArgs {
|
Line 160 sub ParseArgs {
|
} |
} |
} |
} |
|
|
return ($command, $commandarg); |
# Build the result list: |
|
|
|
my @result = ($command, $commandarg); |
|
my $i; |
|
for($i = 0; $i < $paramcount; $i++) { |
|
push(@result, $ARGV[$i]); |
|
} |
|
|
|
return @result; |
} |
} |
|
|
# |
# |
Line 150 if($nparam == 0) {
|
Line 181 if($nparam == 0) {
|
Usage; |
Usage; |
exit -1; |
exit -1; |
} |
} |
print "Will do a $status[0] : $status[1]\n"; |
|
|
print "---- params ---\n"; |
|
for($i = 0; $i < $nparam; $i++) { |
|
print "Param[$i] = $status[$i]\n"; |
|
} |
|
|
exit 0; |
exit 0; |
|
|