Perl, FTP, & Crontab


Subject: Perl, FTP, & Crontab
bthundereagle@aidea.org
Date: Thu Jul 25 2002 - 15:59:52 AKDT


     Here is what I got, I have a perl script that connects to an FTP server.
It works fine, my entire script runs fine when I run it manually. Once,
however, when I put my script into cron to be run, it will run the script but
never seems to even execute the FTP code. I have tried severeal different
methods of connecting to FTP and I never get any errors reported. Here is the 3
different ways I have executed the FTP section:

1 - Using the Net::FTP Module
use Net::FTP;
$ftp = Net::FTP->new('ftp.foo.bar');
$ftp->login('username','password');
$result = $ftp->get("foo.bar");
$ftp->quit;
print "Dowload of $result complete\n";

2 - Executing a second external script from within the primary script
system("/usr/bin/perl -w /sqltest/perl/ftp.pl");

3 - Executing the script directly with perl, and trying to log results
my $perl="/usr/bin/perl";
my $exec="/sqltest/perl/ftp.pl";
open(PERL, "| $perl $exec > perl.log");
close(PERL);

4 - Direct Interaction with 'ftp' and console.
my $ftp="/usr/bin/ftp";
my $afile="foo.bar";
my $host = "ftp.foo.bar";
my $dir = "linux";
open(FTP, "| $ftp $host > ftp.log");
print FTP "ls\n";
print FTP "cd $dir\n";
print FTP "get $afile\n";
#print FTP "delete $afile\n";
print FTP "binary\n";
print FTP "quit\n";
close(FTP); #re-use the fileHandle

     The login is done with .netrc file in the users home directory for all
methods except the 1st method. The 1st method will execute the last print
command properly but that is all I know.

     Is there something about cron that is preventing ftp from running
properly/at all? I have tried changing variables under 'SET' to see if changing
the 'USER' would make a difference but it didn't. Anyone have any ideas? Again
this script will work when run manually, and uses the opening "#!/usr/bin/perl -
w" tag. Last I have also tried running the ftp script through a separate cron
job, but still the file transfer is never made.

     Brian

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Thu Jul 25 2002 - 16:03:23 AKDT