Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Net::FTP works as script, but not CGI

by Cody Pendant (Prior)
on Nov 25, 2008 at 23:31 UTC ( #725971=perlquestion: print w/ replies, xml ) Need Help??
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 ...

Comment on Net::FTP works as script, but not CGI
Download Code
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 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 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 ...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-11-23 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (128 votes), past polls