cotec1
asked on
FTP directory listing...
I have a perl script that puts a file on a ftp site. I need a way to verify that the file is actually on the ftp site. Manually I'd type "dir file_name". I can't seem to get that to work using PERL. Can someone help? I'm also open to "better" ways of verifying that the file was recieved. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
grep{$_ eq $File_to_send} @remote_files;
#or
$ftp->size($File_to_send);
#or
$ftp->size($File_to_send);
# test if that file exists
-e $file_name || &error;
# it has a non-zero size (returns size)
-s $file_name || &error;
## there are other file test operators, about 2 dozen. What do you want to accomplish?
-e $file_name || &error;
# it has a non-zero size (returns size)
-s $file_name || &error;
## there are other file test operators, about 2 dozen. What do you want to accomplish?
ASKER
This is what I did. It works well enough, for now.
@remote_files = $ftp->ls($file);
print "\nChecking for file on ftp site...\n";
print "@remote_files <--(your file should be listed here)\n";
@remote_files = $ftp->ls($file);
print "\nChecking for file on ftp site...\n";
print "@remote_files <--(your file should be listed here)\n";
ASKER
@remote_files = $ftp->ls;
This works, but it returns all of the files in the directory. How can I filter out just the one I sent - $File_to_send?