--- loncom/Attic/lonManage 2003/12/22 12:02:19 1.27 +++ loncom/Attic/lonManage 2003/12/30 11:40:09 1.28 @@ -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 newfile [host] # Push to the lonTabs directory. Note that # must be one of: -# host (hosts.tab) +# hosts (hosts.tab) # domain (domain.tab) # # lonManage -reinit lonc [host] @@ -65,6 +65,7 @@ use English; # Cause I like meaningful use Getopt::Long; use LondConnection; use IO::Poll qw(POLLRDNORM POLLWRNORM POLLIN POLLHUP POLLOUT); +use IO::File; # File scoped variables: @@ -92,7 +93,7 @@ sub Usage { lonManage [--myname=host --hosts=table] --push= newfile [host] Push to the lonTabs directory. Note that 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 @@ sub BuildEditScript { 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 @@ sub BuildEditScript { # is the name of an alternate configuration file to read in # standalone mode. # -sub ReadConfig { +sub ReadConfig { @@ -516,6 +529,7 @@ sub Transact { } # Body is now built... transact with lond.. + print "Final command: '$request'\n"; my $answer = subreply($request, $host); print "$answer\n"; @@ -560,7 +574,7 @@ sub PushFile { my @table = ; # 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);