Bon alors voila mon script
$ping = "/bin/ping -c 2";
$url = "ping.cgi";
$title ="Ping de serveur";
if ($ENV{'CONTENT_LENGTH'} ne '') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@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;
$FORM{$name} = $value;
}
}
$FORM{'host'} =~ s/(\W)/\\$1/g;
print "Content-type:text/html\n\n";
print "<HTML>\n <HEAD><TITLE>$title</TITLE></HEAD><BODY BGCOLOR=\"#FFFFFF\" LINK=\"#FFFFFF\" VLINK=\"#FFFFFF\" ALINK=\"#FFFFFF\"> ";
if ($FORM{'host'} eq ''){
print <<EOFHTML;
<FORM METHOD="POST" ACTION="$url">
<TABLE WIDTH="350" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR ALIGN="CENTER"><TD BGCOLOR="#ffbc2a"> <BR><INPUT TYPE="TEXT" SIZE="18" MAXSIZE="40" NAME="host" VALUE="host.domain.com"><BR> </TD><TD BGCOLOR="#000000"> <BR><INPUT TYPE="SUBMIT" VALUE="CHECK"><BR> </TD></TR></TABLE>
EOFHTML
}
else
{
$txt = `$ping $FORM{'host'}`;
open (A,">/home/thegrato/www/ping.txt" ) || die "impossible d'ouvrir le fichier";
print A $txt;
close(A);
my @lignes;
my $compteur = 0;
open(B,"ping.txt" )|| die ;
while (<B> )
{
do
{
push (@lignes, $_);
++$compteur;
} while ($compteur != 10);
last;
}
chomp ($lignes[7]);
($last_number=$lignes[7])=(~/\/([^a-zA-Z\/]+)\s/);
close (B);
print $last_number;
}
print "</BODY></HTML>";
exit 0;
Apparemment le last ne pose pas vraiment probleme... j'ai essaye de retirer le do et/ou le last mais ça change rien au probleme...