[SP-pm] CGI Net::traceroute deveria funcionar?

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Mon Dec 8 18:42:12 PST 2008


Olá não consigo entender porque não funciona com CGI meu script:

#!/usr/bin/perl

BEGIN {
    my $homedir = ( getpwuid($>) )[7];
    my @user_include;
    foreach my $path (@INC) {
        if ( -d $homedir . '/perl' . $path ) {
            push @user_include, $homedir . '/perl' . $path;
        }
    }
    unshift @INC, @user_include;
}


use strict;
use warnings;

use CGI qw/:standard/;
use Template;
use Net::Traceroute;
$| = 1;

# some useful options (see below for full list)
my $config = {
INTERPOLATE  => 1,   # expand "$var" in plain text
INCLUDE_PATH => '/home/smartcam/public_html/cgi-bin/',  # or list ref
POST_CHOMP   => 1,   # cleanup whitespace
PRE_PROCESS  => 'header.info',# prefix each template
EVAL_PERL=> 1,   # evaluate Perl code blocks
};

# create Template object
my $template = Template->new($config);


# specify input filename, or file handle, text reference, etc.
my $input = 'tracert.tt';

# process input template, substituting variables
$template->process($input) || die $template->error();

print start_form,
"Informe o endereço: ",textfield('tracert'),p,
submit,
end_form,
hr,"\n";

if ( param() ) {
my $host = param('tracert');
my $tr = Net::Traceroute->new(host=> "$host");
    if($tr->found) {
        my $hops = $tr->hops;
    for ( my $i = 0;$i <= 10;$i++ ) {
        if($hops > 1) {
            print p( "Tracert: " .
                $tr->hop_query_host($tr->hops - $i, 0) );
        }
    }
}
}
print end_html();
-- 
Procuro emprego C.V:
http://danielmantovani.awardspace.com/

print
"\x54\x68\x65\x20\x53\x69\x6c\x65\x6e\x74\x20\x47\x75\x61\x72\x64\x69\x61\x6e",$/
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20081209/646832ea/attachment.html>


More information about the SaoPaulo-pm mailing list