-----Original Message-----
From: Gibson, Brian [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 15, 2001 15:07
To: [EMAIL PROTECTED]
Subject: problem writing to fileCan 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 directoryforeach $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;
}
Title: problem writing to file
You setup $logfile as an append, but you openOUT as
output vs using the logfile append?
open (OUT, "> copy.logs");
-> open (OUT, "$logfile");
Wags ;)
- problem writing to file Gibson, Brian
- Wagner-David
