Hello, I am working on migrating from and old server to a newer box. The old server was using a RedHat Enterprise distro that we no longer have a support contract for. As a result our server installation department has configured the new machine with the latest Fedora Core release. I began moving my CGI scripts over this week and am running into troubles. If I run the scripts from the command line (sudo root) everything runs fine. However, when calling them from a web form (Apache) they are not performing their required tasks: For example: The following snippet is supposed to grab the web output and place it into a file:
$tempfileone = "/var/www/cgi-bin/logs/ipsectest/iptestscript$userips[$ +ipcontrol].txt"; $urlone = "http://notgivingthesite/cgi-bin/block-lookup\?$userips[$ipc +ontrol]"; $mechone = WWW::Mechanize->new(); print Dumper $mechone->get( $urlone, ':content_file' => $tempfileone ) +;
With the Dumper tag, I get the following:
$VAR1 = bless( { '_content' => '500 Can\'t connect to notgivingthesite +:80 (Bad hostname \'notgivingthesite\') ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal +response', 'client-date' => 'Wed, 08 Apr +2009 13:34:36 GMT', 'content-type' => 'text/plain' }, 'HTTP::Headers' ), '_msg' => 'Can\'t connect to notgivingthesite:80 (Bad + hostname \'notgivingthesite\')', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://notgivingthesite/cgi-bin/block-lookup?209.18.32.55')}, 'URI:: +http' ), '_headers' => bless( { 'user-a +gent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', 'accept +-encoding' => 'gzip' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' ); $VAR1 = undef;
Again, from the command line everything works just fine. This snippet takes a given IP and places it in a reversed format (10.1.2.6 became 6.2.1.10) and then looks up the PTR record. It should then output to the browser the name lookup for the IP. Unfortunately it only returns a "could not get socket" error:
$ips = inet_aton("$userips[$ipcontrol]"); $forward = gethostbyaddr($ips, AF_INET); $reverselu = gethostbyname("$forward"); $reverse = inet_ntoa($reverselu) if ($reverselu); my $revIP = join(".", reverse(split(/\./, $userips[$ipcontrol]))); $|=1; print Dumper $query = $resolver->query("$revIP.in-addr.arpa.","PTR"); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "PTR"; print " ", $rr->ptrdname; $ptr = $rr->ptrdname; } print "<BR>"; } else { print " <STRONG><font color=\"red\">", $resolver->errorstring, "\n +"; $ptr = "NXDOMAIN"; print "</STRONG></font><BR>"; $testcondition = 1; } $|=0;
The resulting HTML output looks like the following:
<STRONG><font color="red">could not get socket </STRONG></font><BR>
Again, from CLI works just fine and on the old server it works just fine. I beleive this to be an Apache issue since forcing the scripts to run via CLI works just fine. Can anyone assist in this? My server guy is stumped at this time and says Apache is setup correctly (ie near default config). Any assistance or guidance will be greatly appreciated. Thank You

In reply to Perl?Apache issue on newly installed server by Dranzaz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.