Hello Wise Monks:

Let me explain a situation I am having a problem on a perl module. This module sends via FTP a file to a directory and then moves (rename) that file to another directory with another name, this last step is also done via ftp.

In order to do this I use the FTP.pm module. However once in a while I received an error message from the rename operation when doing the move part, I wrote down logs in the code to see what happens and I get 550 FTP code Error. The code I use is the followinig:

unless ($returncode = $self->{ftp}->rename($oldName, $newName)) { $msg=$self->{ftp}->message(); $code=$self->{ftp}->code(), MercMsg::RtrReportInfo(10001,"error el rename del fichero", "ft +p message",$code.": ".$msg,"10005"); return 0; }

In my case the rename returns an error code (see bellow) but the file has been move correctly, the error message is:

Run Time Desc: 550: rename: No such file or directory.

My question is: Does anyone know why this happen? Is the rename operation atomic like a transaction? This has happen a couple of times and the file has been moved in both ocasions correctly but the ftp rename has return error.

EDIT: -----------

The target directory exists for sure due to fact that there are anothter 3 instances running at the same time (moving other files) and didn't have that problem. The files in the target directory are being taken away once in a while, it may be that the target file is taken after the rename is done but before the file handle is closed (I am not sure about this) by thte rename. Also the file hasa been correctly moved in any case. Thanks for answer bart. :-)

EDIT2: -----------

This has happen also on a NFS copy a couple of months ago.

The original file is not there anymore after the error has been return.

Our system is mounted on a Digital Tru64 OS

Francisco Jaen


In reply to Question about FTP.pm rename operation by fjaenale

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.