File:  [LON-CAPA] / loncom / cgi / ping.pl
Revision 1.4: download - view: text, annotated - select for diffs
Tue Feb 25 20:50:31 2003 UTC (21 years, 2 months ago) by www
Branches: MAIN
CVS tags: version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, conference_2003, HEAD
When doing the transition to LONCAPA::Configuration, there should not have
been a "my" in front of the perlvar hash.

    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: my %perlvar;
   16: 
   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: 
   33: # --------------------- Read loncapa.conf (and by default loncapa_apache.conf).
   34: my $perlvarref=LONCAPA::Configuration::read_conf('loncapa.conf');
   35: %perlvar=%{$perlvarref};
   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
   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>