Script perl ...

Antonio Laterza fast6@lists.bofh.it
Tue Oct 1 07:25:21 2002


Non ho capito esattamente dove siete arrivati con le prove e con le funzionalitą del CGI, io ho
fatto il mio cgi di prova e il file delle password che ho utilizzato che riporto nel seguito (ho
ricopiato il form html di Sound):

<pre> 
#!/usr/bin/perl -w
use strict;
my $request_method;
my $form_info;
my $size_of_form_information;
my ($field_name, $password,$user);
$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
          $form_info = $ENV{'QUERY_STRING'};
} else {
      $size_of_form_information = $ENV{'CONTENT_LENGTH'};
      read (STDIN, $form_info, $size_of_form_information);
}
($field_name, $user) = split (/=/, $form_info);
print "Content-type: text/html", "\n\n";
if ($field_name ne "user") {
&form_iniziale();
}

##Formato del file ./filepwd
### commento
##password        3ffe:1001:0212:1234::/64
open FH, "< ./filepwd" or die "Error opening secret file\n";
while (<FH>) {
  next if /^#/;
  #print $_;
  chomp ();
  #print "\n";
  my  ($password,$address_ipv6)= split / +/;
  if ($user eq $password) {
    print "Script ... in esecuzione con parametro: $address_ipv6","\n";
    #qui va inserita la chiamata allo script
    # `./nome_script $address_ipv6`
    last;
  }
}
close FH;

sub form_iniziale {
print "<html>
<head>
<title>Fast6 Tunnel Broker</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body bgcolor=\"#EEEEEE\">
<table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"30\" align=\"center\">
  <tr bgcolor=\"#FFFFFF\"> 
    <td>
      <div align=\"center\">
        <p><font size=\"7\">Fast6 Tunnel Broker</font></p>
        <p align=\"center\"><form method=get name=\"/cgi-bin/cgi-perl.pl\">Inserisci il tuo codice
identificativo: 
        <input type=password size=\"20\" name=\"user\">
        <input type=\"submit\" value=\" Procedi \"></form></p>
      </div>
    </td>
  </tr>
</table>
</body>
</html>
";
}

</pre>

e il file ./filepwd

# commento
password        3ffe:1001:0212:1234::/64

In attesa... augura una buona giornata a tutti.


______________________________________________________________________
Mio Yahoo!: personalizza Yahoo! come piace a te 
http://it.yahoo.com/mail_it/foot/?http://it.my.yahoo.com/