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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 30 Dec 2003 11:40:09 -0000


foxr		Tue Dec 30 06:40:09 2003 EDT

  Modified files:              
    /loncom	lonManage 
  Log:
  Actually read the edit config file and apply it
  
  
Index: loncom/lonManage
diff -u loncom/lonManage:1.27 loncom/lonManage:1.28
--- loncom/lonManage:1.27	Mon Dec 22 07:02:19 2003
+++ loncom/lonManage	Tue Dec 30 06:40:09 2003
@@ -3,9 +3,9 @@
 #
 #  lonManage supports remote management of nodes in a LonCAPA cluster.
 #
-#  $Id: lonManage,v 1.27 2003/12/22 12:02:19 foxr Exp $
+#  $Id: lonManage,v 1.28 2003/12/30 11:40:09 foxr Exp $
 #
-# $Id: lonManage,v 1.27 2003/12/22 12:02:19 foxr Exp $
+# $Id: lonManage,v 1.28 2003/12/30 11:40:09 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,7 +36,7 @@
 #    lonManage  -push   <tablename>  newfile  [host]
 #        Push <tablename> to the lonTabs directory.  Note that
 #        <tablename> must be one of:
-#           host  (hosts.tab)
+#           hosts  (hosts.tab)
 #           domain (domain.tab)
 #
 #    lonManage  -reinit lonc [host]
@@ -65,6 +65,7 @@
 use Getopt::Long;
 use LondConnection;
 use IO::Poll qw(POLLRDNORM POLLWRNORM POLLIN POLLHUP POLLOUT);
+use IO::File;
 
 # File scoped variables:
 
@@ -92,7 +93,7 @@
  lonManage  [--myname=host --hosts=table] --push=<tablename>  newfile  [host]
         Push <tablename> to the lonTabs directory.  Note that
         <tablename> must be one of:
-           host  (hosts.tab)
+           hosts  (hosts.tab)
            domain (domain.tab)
 
  lonManage [--myname=host --hosts=table] --reinit=lonc [host]
@@ -417,13 +418,25 @@
    my $TableType    = shift;
    my $ScriptName   = shift;
    
-   #Stub
+   my $fh  = new IO::File "< $ScriptName";
+   if (! (defined $fh)) {
+       print "Unable to open script file: $ScriptName \n";
+       Usage;
+       exit -1;
+   }
    
-   my @EditScript = (
-      "$TableType\:append|".
-         "nscll2|nscl\:library\:lonkashy.nscl.msu.edu\:35.8.32.89\n"
-	."delete|nscll2"
-      );
+   my @EditScript;
+   my $scriptline = "$TableType\:"; # First leads with e.g. hosts:
+   while (! $fh->eof()) {
+       my $line = <$fh>;
+       chomp $line;
+       if($line ne "\n") {
+	   $scriptline .= "$line\n";
+	   push(@EditScript, $scriptline);
+	   $scriptline = "";
+       }
+   }
+
    return \@EditScript;
 }
 #  Read the loncapa configuration stuff.  If ForeignHostTab is empty,
@@ -432,7 +445,7 @@
 #  is the name of an alternate configuration file to read in 
 #  standalone mode.
 #
-sub ReadConfig {
+sub ReadConfig {  
 
 
    
@@ -516,6 +529,7 @@
    }
     # Body is now built... transact with lond..
     
+    print "Final command: '$request'\n";
     my $answer = subreply($request, $host);
 
     print "$answer\n";
@@ -560,7 +574,7 @@
    my @table = <TABLEFILE>;	#  These files are pretty small.
    close TABLEFILE;
 
-   if( ($tablename eq "host")    ||
+   if( ($tablename eq "hosts")    ||
        ($tablename eq "domain")) {
       print("Pushing $tablename to $host\n");
       Transact($host, "pushfile:$tablename",\@table);