--- loncom/Attic/lonManage 2003/08/12 10:40:44 1.4 +++ loncom/Attic/lonManage 2003/08/12 10:55:42 1.5 @@ -3,9 +3,9 @@ # # lonManage supports remote management of nodes in a LonCAPA cluster. # -# $Id: lonManage,v 1.4 2003/08/12 10:40:44 foxr Exp $ +# $Id: lonManage,v 1.5 2003/08/12 10:55:42 foxr Exp $ # -# $Id: lonManage,v 1.4 2003/08/12 10:40:44 foxr Exp $ +# $Id: lonManage,v 1.5 2003/08/12 10:55:42 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,6 +50,9 @@ # not the IP address of the host. # # $Log: lonManage,v $ +# 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 # Get switch parsing right. # @@ -111,6 +114,7 @@ USAGE sub ParseArgs { my $pushing = ''; my $reiniting = ''; + if(!GetOptions('push=s' => \$pushing, 'reinit=s' => \$reinitting)) { return (); @@ -118,17 +122,36 @@ sub ParseArgs { # Require exactly one of --push and --reinit - my $command = ''; + my $command = ''; my $commandarg = ''; + my $paramcount = @ARGV; # Number of additional arguments. + + 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 '') { return (); } else { + $command = 'push'; $commandarg = $pushing; } } + if ($reinitting ne '') { + + # --reinit takes in addition just a host name + + if($paramcount != 1) { + print "Bad count $paramcount\n"; + return (); + } if($command ne '') { return (); } else { @@ -137,7 +160,15 @@ 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; } # @@ -150,7 +181,11 @@ if($nparam == 0) { Usage; 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;