File:  [LON-CAPA] / loncom / cgi / ping.pl
Revision 1.2: download - view: text, annotated - select for diffs
Sat May 11 21:31:41 2002 UTC (22 years ago) by harris41
Branches: MAIN
CVS tags: version_0_5_1, version_0_5, version_0_4, stable_2002_july, STABLE, HEAD
Using LONCAPA::Configuration::read_conf
BUG 129

    1: #!/usr/bin/perl
    2: 
    3: # The LearningOnline Network with CAPA
    4: # ping cgi-script
    5: 
    6: 
    7: $|=1;
    8: 
    9: use lib '/home/httpd/lib/perl/';
   10: use LONCAPA::Configuration;
   11: 
   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: 
   31: # ------------------------------------------- Read access.conf and loncapa.conf
   32: my $perlvarref=LONCAPA::Configuration::read_conf('access.conf','loncapa.conf');
   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
   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>