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

Hi, I'm sorry if this has been posted before somewhere but I can't seem to find it in searches exactly. I'm using a perl script to automatically pgp encrypt and upload a file via ftp. The script works well (seemingly) if it runs either off my shell or in cron. The problem I'm having and can't figure out is, when it runs in cron, for some reason the binary type I is never set even when I manually set it prior to uploading. It oddly runs just fine when I execute it from the terminal though. I was wondering if there is some env setting that might need to be set. The perl script I'm using is basically straight out of the cookbook (for ftp) with the exception that I'm adding a type I statement. I've done packet captures and compared both the manual and automated and never see same between them. Very odd. Any suggestions would be appreciated. Thanks in Advance.

Replies are listed 'Best First'.
Re: Net::Ftp and cron
by freddo411 (Chaplain) on Jun 17, 2003 at 22:52 UTC
    You'll want to post your code if you want to get more meaningful responses.

    You might try:

    $ftp=Net::FTP->new("ftp.microsoft.com", Debug => 1, );
    to catch more info from Net::FTP

    Also, I have had problems using cron because the path and/or env and/or current working directory wasn't the same as when I ran it from the cmd line. This may cause the script problems in finding libraries, external commands, reading and/or writing files were you expect them to be etc. A simple-minded solution to the cwd problem is have the perl script cd to its own location at the top of the script.

    Also, is the crontab that of the user that was logged in on the cmd line that you used to run the test?

    -------------------------------------
    Nothing is too wonderful to be true
    -- Michael Faraday

      Hi, sorry it's taken me long to reply. I wouldn't return more information until I really went over the packet dumps and debug info. I manged to solve it by throwing in a sleep for 5 seconds before I closed the connection. Not sure why exactly that is but perhaps it was truncating the pgp file and thus causing corruption. Thanks for the advice. eo