Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

The error message you see is generated initially by IO::Socket::INET's configure method when it has called its _get_addr() method which has in turn called gethostbyname() which is what will have choked in the first place. (Probably)

To debug write a CGI like this:

#!/usr/bin/perl print "Content-Type: text/html\n\n"; my $host = gethostbyname($ENV{QUERY_STRING}); print $host ? "Got host $host\n" : "Choked!"; call it like: http://yourdomain.com/cgi-bin/gethost?perlmonks.org

Assuming you call it gethost you should see it print 4 binary bytes out as the host name. If it says choked you have an issue with gethostbyname under CGI. If so it will be perms as your CGI will not be running as you.

An alternative way to prove it is perms is

su nobody ./script.pl

ie change to the user nobody/apache or whatever webserver runs as and see if it chokes. I am making the assumption that you are testing it off the command line *on the same box* that is running the CGI? If not all bets are off!

If gethostbyname is working your IO::Socket::INET has issues. The most probable reason for this is that you have 2 perls on your system. The webserver will probably do

./script.pl

To exec the script and thus use the shebang. Probably. It could be running mod_perl or lots of other stuff but that is the high probability. If you are executing it as perl script.pl then you could quite easily be running it with a different perl to the web server. We have 5.6.1, 5.6.2, 5.8.2 and 5.8.3 on our devel box. perl will currently give you 5.6.2 but...... Let us know your results. div class="pmsig">

cheers

tachyon


In reply to Re: LWP::UserAgent connection problem as CGI by tachyon
in thread LWP::UserAgent connection problem as CGI by bassplayer

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (3)
    As of 2014-11-28 04:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (193 votes), past polls