File:  [LON-CAPA] / loncom / cgi / ping.pl
Revision 1.3: download - view: text, annotated - select for diffs
Mon Sep 9 14:18:56 2002 UTC (21 years, 8 months ago) by harris41
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, HEAD
remove access.conf; loncapa.conf is read and BY DEFAULT loncapa_apache.conf
is always read (AT THE END)

    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 loncapa.conf (and by default loncapa_apache.conf).
   32: my $perlvarref=LONCAPA::Configuration::read_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>