in reply to Bad hostname

Find a way to get debug messages from your script. This may be print STDERR, a temp log file in /tmp or anything else. Then print the exact URL you use for the LWP call and also the error message from your LWP handle.
You may not call your script at all, you may get wrong parameters because of ', " or $ problems or something else.
You should also print $ENV{http_proxy}, because your script may run in an environment which uses a proxy without your knowledge.
If really everything is fine, try a
print logfile `ping -c 1 host.name.com 2>&1`;

Replies are listed 'Best First'.
Re^2: Bad hostname
by alvise (Acolyte) on Sep 13, 2009 at 19:49 UTC

    Hi Sewi:

    > Find a way to get debug messages > from your script. This may be > print STDERR, a temp log file > in /tmp or anything else.

    yes, I already print everything into a log file

    > Then print the exact URL you > use for the LWP call and also > the error message from your > LWP handle.

    the URL is fine

    > You should also print $ENV{http_proxy}

    no proxy found

    Anycase: the exact message that I get from the KWP user agent is the following:

    500 Can't connect to www.sandbox.paypal.com:80 (Bad hostname 'www.sandbox.paypal.com')

    And if I add the hostname into /etc/hosts the status line turns to:

    500 Can't connect to www.sandbox.paypal.com:80 (Permission denied)

    and this latter status line is also given if I change the URL with the corresponding IP:

    500 Can't connect to 216.113.191.82:80 (Permission denied)

    but this doesn't prove anything because maybe there could be many virtual hosts with the same IP.

    Finally, as you are suggesting:

    > If really everything is fine, try a > print logfile `ping -c 1 host.name.com 2>&1`;

    I tried to ping the PayPal SandBox without involving LWP, I just pinged it with backticks. This is the returned message:

    unknown host www.sandbox.paypal.com

    It looks like DNS is not resolved, but only when the script is called by Apache. When the script is called from the command line the DNS is properly resolved, and the script works just fine.

    BTW: on another web server, with Fedora 4 instead of Fedora 5, the entire set of scripts work fine even when called by Apache.

    Thanks for your help. Alvise.

      BTW: on another web server, with Fedora 4 instead of Fedora 5, the entire set of scripts work fine even when called by Apache.

      Does your Fedora 5 box maybe have SELinux enabled?  (it could in theory be responsible for such problems)

      Try setenforce 0  to (temporarily) disable SELinux for testing purposes...  (see also selinux-faq-fc5)

        Hi almut: "setenforce 0" solved my problem. Many many thanks from Alvise !!!