in reply to Re^16: transfer a file via SFTP
in thread transfer a file via SFTP

Great!!

You should be able to move the setup of the sftp connection outside (before) the loop. One connection should suffice to transfer several files.

When you move the log file within the loop, the first time it will work but after that the file isn't there. If you want a separate log file for each file processed then you should probably set this up separately for each file within the loop.

Replies are listed 'Best First'.
Re^18: transfer a file via SFTP
by cc (Beadle) on Aug 05, 2009 at 16:31 UTC
    This script looks every 5 minutes for a .txt file.
    I'd like to die the script if .txt file is not there, otherwise it creates a lot of backup directories.
    Can u pls help me to change it?

      You could add

      die unless(-e $file);

      There are many file tests available. You can read about them in -X.

        sorry to disturb u again, but I have 2 problems:

        1.) I don't know howto move setup of the sftp connection outside the loop.

        2.) to die if the *.txt file is not there, I tried to add these lines:
        chdir "/srv" or die "/srv: $!\n"; -f "/srv/*.txt" or die "NO FILE NO TRANSFER !\n";
        but it doesn't work.

        greeings cc