#!/usr/local/bin/perl -w package WWd; use lib '/u/gage/xmlrpc/daemon/'; use Webwork; ############utilities sub echo { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $in = shift; return(ref($in). " $in "); } sub listLib { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $in = shift; return( Webwork::listLib($in) ); } sub renderProblem { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $in = shift; return( Webwork::renderProblem($in) ); } sub readFile { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $in = shift; return( Webwork::readFile($in) ); } sub hello { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); print "Receiving request for hello world\n"; return "Hello world?"; } sub pretty_print_rh { my $rh = shift; my $out = ""; my $type = ref($rh); if ( ref($rh) =~/HASH/ ) { foreach my $key (sort keys %{$rh}) { $out .= " $key => " . pretty_print_rh( $rh->{$key} ) . "\n"; } } elsif ( ref($rh) =~ /SCALAR/ ) { $out = "scalar reference ". ${$rh}; } elsif ( ref($rh) =~/Base64/ ) { $out .= "base64 reference " .$$rh; } else { $out = $rh; } if (defined($type) ) { $out .= " type = $type \n"; } return $out; } sub tth { shift if UNIVERSAL::isa($_[0] => __PACKAGE__); my $in = shift; my $tthpath = "/usr/local/bin/tth"; my $out; $inputString = "</dev/null"; #it's not clear why another command is needed. if (-x $tthpath ) { my $tthcmd = "$tthpath -L -f5 -r 2>/dev/null " . $inputString; if (open(TTH, "$tthcmd |")) { local($/); $/ = undef; $out = ; $/ = "\n"; close(TTH); }else { $out = "
there has been an error in executing $tthcmd
"; } } else { $out = "
Can't execute the program tth at |$tthpath|
"; } #return "\r\n\r\n" . $out . "\r\n\r\n"; return $out; } 1;