Annotation of loncom/cgi/ping.pl, revision 1.4

1.1       www         1: #!/usr/bin/perl
                      2: 
                      3: # The LearningOnline Network with CAPA
                      4: # ping cgi-script
                      5: 
                      6: 
                      7: $|=1;
                      8: 
1.2       harris41    9: use lib '/home/httpd/lib/perl/';
                     10: use LONCAPA::Configuration;
                     11: 
1.1       www        12: use IO::File;
                     13: use IO::Socket;
                     14: 
1.4     ! www        15: my %perlvar;
        !            16: 
1.1       www        17: # -------------------------------------------------- Non-critical communication
                     18: sub reply {
                     19:     my ($cmd,$server)=@_;
                     20:     my $peerfile="$perlvar{'lonSockDir'}/$server";
                     21:     my $client=IO::Socket::UNIX->new(Peer    =>"$peerfile",
                     22:                                      Type    => SOCK_STREAM,
                     23:                                      Timeout => 10)
                     24:        or return "con_lost";
                     25:     print $client "$cmd\n";
                     26:     my $answer=<$client>;
                     27:     chomp($answer);
                     28:     if (!$answer) { $answer="con_lost"; }
                     29:     return $answer;
                     30: }
                     31: 
                     32: 
1.3       harris41   33: # --------------------- Read loncapa.conf (and by default loncapa_apache.conf).
                     34: my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
1.4     ! www        35: %perlvar=%{$perlvarref};
1.2       harris41   36: undef $perlvarref; # remove since sensitive and not needed
                     37: delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
                     38: delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
1.1       www        39: 
                     40: $testhost=$ENV{'QUERY_STRING'};
                     41: $testhost=~s/\W//g;
                     42: 
                     43: print "Content-type: text/plain\n\n".
                     44:       &reply('ping',$testhost)."\n";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>