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

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: 
                     15: # -------------------------------------------------- Non-critical communication
                     16: sub reply {
                     17:     my ($cmd,$server)=@_;
                     18:     my $peerfile="$perlvar{'lonSockDir'}/$server";
                     19:     my $client=IO::Socket::UNIX->new(Peer    =>"$peerfile",
                     20:                                      Type    => SOCK_STREAM,
                     21:                                      Timeout => 10)
                     22:        or return "con_lost";
                     23:     print $client "$cmd\n";
                     24:     my $answer=<$client>;
                     25:     chomp($answer);
                     26:     if (!$answer) { $answer="con_lost"; }
                     27:     return $answer;
                     28: }
                     29: 
                     30: 
1.3     ! harris41   31: # --------------------- Read loncapa.conf (and by default loncapa_apache.conf).
        !            32: my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
1.2       harris41   33: my %perlvar=%{$perlvarref};
                     34: undef $perlvarref; # remove since sensitive and not needed
                     35: delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
                     36: delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
1.1       www        37: 
                     38: $testhost=$ENV{'QUERY_STRING'};
                     39: $testhost=~s/\W//g;
                     40: 
                     41: print "Content-type: text/plain\n\n".
                     42:       &reply('ping',$testhost)."\n";

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