Link to home
Start Free TrialLog in
Avatar of cotec1
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
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cotec1
cotec1

ASKER

# get list of files from current dir
@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?
Avatar of ozo
grep{$_ eq $File_to_send} @remote_files;
#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?
Avatar of cotec1

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";