--- loncom/lonr 2009/04/17 00:07:00 1.1 +++ loncom/lonr 2009/04/18 23:43:47 1.5 @@ -1,9 +1,9 @@ #!/usr/bin/perl # # The LearningOnline Network with CAPA -# Connect to MAXIMA CAS +# Connect to R CAS # -# $Id: lonr,v 1.1 2009/04/17 00:07:00 www Exp $ +# $Id: lonr,v 1.5 2009/04/18 23:43:47 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -269,7 +269,7 @@ sub make_new_child { }; $command->log_stdout(0); - $command->log_file("$execdir/logs/lonr.session.log"); +# $command->log_file("$execdir/logs/lonr.session.log"); for (my $i=0; $i < $MAX_CLIENTS_PER_CHILD; $i++) { &status('Accepting connections'); @@ -282,7 +282,7 @@ sub make_new_child { while (my $cmd=<$client>) { &status('Processing command'); print $command &unescape($cmd); - my ($reply,$syntaxerr) = &getroutput($command,1); + my ($reply,$syntaxerr) = &getroutput($command); print $client &escape($reply)."\n"; if ($syntaxerr) { last; @@ -316,7 +316,7 @@ sub make_new_child { sub sync { my ($command)=@_; $counter++; - my $expect=$counter.time; + my $expect=$counter; print $command "$expect;\n"; while (1) { my $output=&getroutput($command); @@ -351,7 +351,8 @@ sub getroutput { my $realoutput=''; foreach my $line (split(/\n/,$output)) { $line=~s/\s$//gs; - if (my ($result)=($line=~/^\[\d+\,*\]\s*(.*)/)) { $realoutput.=$result."\n"; } + if ($line=~/^Error\:/) { $syntaxerr=1; next; } + if (my ($result)=($line=~/^\[?\d+\,*\]?\s*(.*)/)) { $realoutput.=$result."\n"; } } if (wantarray) { return ($realoutput,$syntaxerr);