http://www.perlmonks.org?node_id=725971

Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:

I've got an FTP task which, when written as a script and run from the command line, works just fine.

But when run as a CGI, it dies with the $ftp->error "Transfer Aborted" -- which is not much help.

It's exactly the same task, same username and password, same paths, so I'm a bit stuck.

Maybe if I could get the Net::FTP Debug output that would help, but I can't figure out how to do that. Where is it actually being sent, and how can I get it to appear in my browser, or log it to a file?



Nobody says perl looks like line-noise any more
kids today don't know what line-noise IS ...

Replies are listed 'Best First'.
Re: Net::FTP works as script, but not CGI
by Illuminatus (Curate) on Nov 26, 2008 at 00:06 UTC
    One of the most common reasons why a script runs from the command line but not as a CGI is permissions. The web server is probably running as a different user, and may not have read/write where you think it does.
Re: Net::FTP works as script, but not CGI
by almut (Canon) on Nov 25, 2008 at 23:52 UTC

    If you enable debugging (Debug => 1 in the Net::FTP constructor), messages will be sent to stderr, which will typically end up in the web server's error log.  See CGI::Carp for how to redirect them.

Re: Net::FTP works as script, but not CGI
by Cody Pendant (Prior) on Nov 26, 2008 at 00:33 UTC
    Very helpful, both of you. Thanks.

    For the record I had made not one but two of the errors in the Idiot's Guide: I had the wrong permissions and my working directory was not what I thought it was!

    I need more sleep.



    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...