in reply to Re: Re: Re: Re: Re: Re: Re: Problem using Net::FTP
in thread Problem using Net::FTP

hi jarich

thank you very much for your time and HELP
now it works perfectly !
and very sorry, I didn't answer so quickly, because I was in vacation

I have only a small problem:
I try to log the whole process and put:
# log the whole process BEGIN { use CGI::Carp qw(carpout); my $errorlog = "/var/logs/log.txt"; open(LOG, ">$errorlog") or die("Unable to open $errorlog: $!\n"); print LOG "Errors:\n"; carpout(*LOG); }
on the top of the script.

It works and I get the log.
On the end I try to move all files: 2 data files, info file and log.txt to the backup directory:
............................................................ # move the file to the backup subfolder unless(move("$new", "/var/files/out/$subfolder_name")) { print STDERR "Oops! Couldn't move the file: $!"; } system("mv /var/files/info /var/files/out/$subfolder_name"); system("mv /var/logs/log.txt /var/files/out/$subfolder_name"); ............................................................
it works and all files are moved, but I get in the log following error messages :
mv: cannot stat `/var/files/info': No such file or directory
mv: cannot stat `/var/logs/log.txt': No such file or directory

I don't know what's wrong and why I get these error messages.

greetings
cc

Replies are listed 'Best First'.
(Re: x 8) Problem using Net::FTP
by jarich (Curate) on Mar 31, 2004 at 01:30 UTC
    1. Read perldoc File::Copy or if that's too hard read the html version over at CPAN.

    2. Read my previous posts to you, particularly the bits about File::Copy.

    3. Wonder why after the above you're trying to use mv through system when I've shown you a better way.

    4. Realise that you're doing that mv inside a loop so of course the damn files aren't going to be there the next time around the loop!

    5. Change calls to system to use move from File::Copy instead and change these lines to be outside of the second for loop, eg the place where you send the email. Remember to then check that your move succeeded (by using the unless statements like I did).

    6. Rejoice because it all finally works the way it should.

    Hope it helps.

    jarich

      hi jarich

      thanks again !
      with move works well.

      sorry for asking again, but I have other question
      howto check if the first file was transfered succesfully
      and be 100% sure, that the first file is already on the remote server
      and only then send the second file ?
      my really problem is, I cannot send the second file, when the first file is not there.

      greetings
      cc
        Read the documentation. I'm sure it'll tell you what happens if it fails to upload the file. Perhaps it returns false if that happens?

        Once you know what happens after failure, you should be able to cater for that.

        I would presume that your $ftp->put($new) or die "$server: cannot put $new: " . $ftp->message; would be sufficient myself...

        If you're seeing cases where $ftp->put($new) is not returning false and if that's what the documentation says it should and the file is not being successfully transferred then that's a different matter, and one I can't help you with.

        If you are seeing cases like that then you should try to identify under what circumstances that's happening. If you can identify the circumstances, and repeat the problem, but not fix it, then that would make an excellent SOPW question.

        All the best,

        jarich