[LON-CAPA-cvs] cvs: loncom / lonManage

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 12 Aug 2003 10:55:42 -0000


foxr		Tue Aug 12 06:55:42 2003 EDT

  Modified files:              
    /loncom	lonManage 
  Log:
  Complete command line parsing (tested)
  
  
Index: loncom/lonManage
diff -u loncom/lonManage:1.4 loncom/lonManage:1.5
--- loncom/lonManage:1.4	Tue Aug 12 06:40:44 2003
+++ loncom/lonManage	Tue Aug 12 06:55:42 2003
@@ -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 @@
 sub ParseArgs {
     my $pushing   = '';
     my $reiniting = '';
+
     if(!GetOptions('push=s'    => \$pushing,
 	           'reinit=s'  => \$reinitting)) {
 	return ();
@@ -118,17 +122,36 @@
 
     #  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 @@
 	}
     }
 
-    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 @@
     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;