sveera has asked for the wisdom of the Perl Monks concerning the following question:

Hi friends, i have written a basic script for automating ftp of files from source directory to a destination directory on a different host. But how can i get the list of files in the source directory so that i can keep track of the files which went successfully and unsuccessful files ? thanks in advance srini

Replies are listed 'Best First'.
Re: automate ftp using perl
by gellyfish (Monsignor) on Apr 14, 2005 at 11:54 UTC

    You are probably looking for opendir and readdir or glob - there are hundreds of nodes here with examples.

    /J\

      The poster mentions FTP and a different host for a destination. Can you explain how readdir() is going to help check for successful puts here?

      --
      [ e d @ h a l l e y . c c ]

        He may mention that but he actually says : " files from source directory to a destination directory on a different host. But how can i get the list of files in the source directory" - he wants a list of the files in the source i.e. local directory, I'm sure you won't dispute that readdir works there.

        /J\

      Thank you so much gellyfish srini
Re: automate ftp using perl
by Cody Pendant (Prior) on Apr 14, 2005 at 13:04 UTC
    Your question kind of doesn't make sense -- you want to get a list of files in the source directory to see if they've been successfully uploaded to the destination directory?

    The files won't change in the source dir, whether they've been uploaded or not, so the source won't tell you anything.

    If you want to know which files are in the destination directory, connect to it with NET::FTP and get a listing with the ls() function.



    ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
    =~y~b-v~a-z~s; print
Re: automate ftp using perl
by nimdokk (Vicar) on Apr 14, 2005 at 11:56 UTC
    I might suggest getting a directory listing of files using glob (or some other mechanism) then looping through that list one at a time. Also, make sure to check for success or failure on your ftp commands, that will be a good indication. If you are using Net::FTP, you should have everything you need.
      Thankyou very much nimdokk srini