Hi,
I have written a program that ftp's the contents of two directories every 10
minutes, as follows:
=============================================
#!/usr/bin/perl
use strict;
use Net::FTP;
# Declare variables
my $ftp;
my $ftpHost = "*****";
my $ftpUser = "*****";
my $ftpPword = "*****";
my $file;
my $ftpFile;
################
# Main Program #
################
$ftp = Net::FTP->new($ftpHost) or print "No new ftp:$!\n";
$ftp->login($ftpUser, $ftpPword) or print "Problem logging in:$!\n";
runFTP('d_htmFiles', '');
runFTP('d_data', 'data');
$ftp->quit;
print "Sleeping for 10 minutes...\n";
sleep(500);
sub runFTP(){
my $localDir = shift;
my $ftpDir = shift;
if ($ftpDir ne ""){
print "working directory is $ftpDir";
$ftp->cwd($ftpDir) or print "Problem changing directory:$!\n";
} # end of if()
opendir(DIR, $localDir) or die "can't opendir $localDir: $!";
while (defined($file = readdir(DIR))) {
if (!
(substr($file,0,1) eq ".")
){
$ftpFile = "$localDir/$file";
print"\nFTPing $ftpFile... ";
$ftp->put($ftpFile) or print "Problem putting file:$!\n";
}# end of if{}
} # end of while{}
closedir(DIR);
print "\nDone.\n\n";
} # end of runFTP()
=============================================
...the program works fine from the command line, however, when I run it from
another script it hangs.
Example script:
=============================================
#!/usr/bin/perl
print `perl myFTP.pl\n`;
=============================================
Any help much appreciated.
Many thanks,
Piers