Can someone please help me? I wrote a small script that monitors a directory for files and automatically FTPs them to a remote server. It then needs to write the file name to a log file so that we know if succesfully FTPed the file.
The FTP mechanism works fine. However I can't seem to get the script to write to file. I wrote a dummy script opening the same log file from the same location with the same credentials and it worked fine. Can anyone tell what I am doing wrong here?
#!/usr/bin/perl
$logfile = ">>copy.logs";
for (;;) {
#The if loop is used to open the session only if there are files
while (defined($checkit = glob("/home/ftps/*"))){
$ftp = Net::FTP->new('192.168.220.2');
$ftp->login('user','pass');
$ftp->binary();
open (OUT, "> copy.logs");
#The While loop is used to send all files to the destination and then
#clean the directory
foreach $filelist ((glob("/home/files/*"))){
if ($ftp->put($filelist)){
print OUT "$filelist copied\n" or print "didn't log it\n";
unlink($filelist);}
else
{
print OUT "$filelist failed to copy\n";
}
}
}
sleep 10;
close OUT;
}
