分类: BSD
2008-05-05 08:29:07
苗栗縣大湖鄉大南國民小學
#!/usr/bin/sperl5 # 接收傳遞過來的參數 # 將輸入的參數 one by one 取出來 $| = 1; #flush on if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } elsif ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer=$ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $A_hash{$name} = $value; } $server=$A_hash{"server"}; $school=$A_hash{"school"}; $addr=$A_hash{"addr"}; $tel=$A_hash{"tel"}; $fax=$A_hash{"fax"}; # 檢查主機網路是否正常 use Net::Ping ; $p=Net::Ping->new("icmp",1) ; $chk_server = $p->ping($server) ; if ( $chk_server ) { # 如果線路檢查正常,進而以此網頁再去檢查 port 80 print qq~ ~; } else { # 線路檢查結果不通,顯示網站維修的訊息。 do "under_construction.pl"; } $p->close() ;
#!/usr/bin/perl #接收命令行輸入 # 將輸入的參數 one by one 取出來 $| = 1; #flush on if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } elsif ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer=$ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $A_hash{$name} = $value; } $server=$A_hash{"server"}; $school=$A_hash{"school"}; $addr=$A_hash{"addr"}; $tel=$A_hash{"tel"}; $fax=$A_hash{"fax"}; use IO::Socket; my ($line, $port, $sock, @servers); #掃描通訊埠 $port = 80 ; # 開始掃描 port 80 $sock = IO::Socket::INET->new( PeerAddr => $server, PeerPort => $port, Proto => 'tcp'); if ($sock) { # 如果 port 80 正常,整個網站轉址過去 print qq~ 線路檢查正常,網站轉換中,請稍候...... ~; } else { # port 80 不通時,顯示施工中的訊息 do "under_construction.pl"; }