Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

What modules required

by Anonymous Monk
on Oct 11, 2006 at 18:48 UTC ( [id://577692]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I want to install cgi script, called 'ipinfo', it show info about visitors IP and some other relevant info.
It looks this script required some specific modules, not sure what exactly. Here is top part of script:
#!/usr/bin/perl # # SmoothWall CGIs # # This code is distributed under the terms of the GPL # # (c) The SmoothWall Team # # (c) 2002 Josh Grubman - Multiple registry IP lookup code # # $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $ # use IO::Socket; use strict; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; require 'CONFIG_ROOT/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";

2006-10-12 Retitled by ysth, as per Monastery guidelines
Original title: 'What modules requied?'

Replies are listed 'Best First'.
Re: What modules required
by VSarkiss (Monsignor) on Oct 11, 2006 at 19:24 UTC

    Well, IO::Socket and strict are standard, so that should "just work" if your perl is properly installed.

    The other three:

    require 'CONFIG_ROOT/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl";
    are some local files. Without further information it's hard to say, but you should look for a directory CONFIG_ROOT containing the file general-functions.pl. Presumably that will contain the variable $General::swroot that is required to generate the other file names. If nothing else, run the script from the directory containg the CONFIG_ROOT directory to at least get an idea of whether it will work or no.

    But I'm really just speculating. With custom code you really need to find the author or maintainer. In a public forum like this, you have to provide lots more detail.

      I just expected that that script contains all, and does not require additional scripts.
      Not sure about this scripts:.

      require 'CONFIG_ROOT/general-functions.pl';
      require "${General::swroot}/lang.pl";
      require "${General::swroot}/header.pl";

      I tried run script, get Internal Server error. Provider also checked script and say, that this error appears when the script is run:

      root@web1 cgi-bin# sudo -u gareks ./ipinfo.cgi
      Unterminated <> operator at ./ipinfo.cgi line 90.

      here is full code:
      #!/usr/bin/perl # # SmoothWall CGIs # # This code is distributed under the terms of the GPL # # (c) The SmoothWall Team # # (c) 2002 Josh Grubman - Multiple registry IP lookup code # # $Id: ipinfo.cgi,v 1.4.2.3 2005/02/22 22:21:56 gespinasse Exp $ # use IO::Socket; use strict; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; require 'CONFIG_ROOT/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %cgiparams=(); &Header::showhttpheaders(); &Header::getcgihash(\%cgiparams); $ENV{'QUERY_STRING'} =~s/&//g; my @addrs = split(/ip=/,$ENV{'QUERY_STRING'}); my %whois_servers = ("RIPE"=>"whois.ripe.net","APNIC"=>"whois.apnic.ne +t","LACNIC"=>"whois.lacnic.net"); &Header::openpage($Lang::tr{'ip info'}, 1, ''); &Header::openbigbox('100%', 'left'); my @lines=(); my $extraquery=''; foreach my $addr (@addrs) { next if $addr eq ""; $extraquery=''; @lines=(); my $whoisname = "whois.arin.net"; my $iaddr = inet_aton($addr); my $hostname = gethostbyaddr($iaddr, AF_INET); if (!$hostname) { $hostname = $Lang::tr{'lookup failed'}; } my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, PeerPort + => 43, Proto => 'tcp'); if ($sock) { print $sock "$addr\n"; while (<$sock>) { $extraquery = $1 if (/NetType: Allocated to (\S+)\s+/); push(@lines,$_); } close($sock); if ($extraquery) { undef (@lines); $whoisname = $whois_servers{$extraquery}; my $sock = new IO::Socket::INET ( PeerAddr => $whoisname, +PeerPort => 43, Proto => 'tcp'); if ($sock) { print $sock "$addr\n"; while (<$sock>) { push(@lines,$_); } } else { @lines = ( "$Lang::tr{'unable to contact'} $whoisname" + ); } } } else { @lines = ( "$Lang::tr{'unable to contact'} $whoisname" ); } &Header::openbox('100%', 'left', $addr . ' (' . $hostname . ') : ' +.$whoisname); print "\n"; foreach my $line (@lines) { print &Header::cleanhtml($line,"y"); } print "\n"; &Header::closebox(); } print < $Lang::tr{'back'} END ; &Header::closebigbox(); &Header::closepage();
        The error "Unterminated <> operator at ./ipinfo.cgi line 90." is from this line:
        print <
        which appears to be a typo, most likely for a "here document" reference:
        print <<END
        But the reference to ${General::swroot} has just got to be defined in CONFIG_ROOT/general-functions.pl, so you need a copy of that file, as well as lang.pl and header.pl. There is no way that this can be a complete script by itself.
        Hm. This snippet
        print < $Lang::tr{'back'} END

        should be something like

        print <<END; $Lang::tr{'back'} END

        what do the folks at SmoothWall say to that?

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: What modules required
by Joost (Canon) on Oct 11, 2006 at 19:08 UTC
Re: What modules required
by chromatic (Archbishop) on Oct 11, 2006 at 19:21 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://577692]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found