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!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim RyanIT ConsultantCommented:
If you are using the Net::FTP module,
use Net::FTP;
$ftp = Net::FTP->new($host_ip);
# get list of files from current dir
@remote_files = $ftp->ls;

To be really sure your file got there, you could fetch it back again as a different name and check the size is the same as the one you sent.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cotec1Author Commented:
# 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?
grep{$_ eq $File_to_send} @remote_files;
# 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?
cotec1Author Commented:
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";
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.