• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Really odd FTP issue

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Really odd FTP issue

    I've just been asked about a really odd FTP issue.
    A text file is created on one server and then FTP'd to another.
    The next day a new file is created with the same name and FTP'd across.

    Here is the problem: The new file does not replace the old one, but seems to be overwriting the data in it.
    That wouldn't be a problem if the new file was always bigger than the old one, but if the new file is smaller in size than the old one, then you see the e.g. 50 rows of the new file, and row 51 onwards is actually row 51 onwards of the old file.

    Any thoughts?
    …Maybe we ain’t that young anymore

    #2
    Originally posted by WTFH View Post
    I've just been asked about a really odd FTP issue.
    A text file is created on one server and then FTP'd to another.
    The next day a new file is created with the same name and FTP'd across.

    Here is the problem: The new file does not replace the old one, but seems to be overwriting the data in it.
    That wouldn't be a problem if the new file was always bigger than the old one, but if the new file is smaller in size than the old one, then you see the e.g. 50 rows of the new file, and row 51 onwards is actually row 51 onwards of the old file.

    Any thoughts?
    You've got a dodgy FTP client which is opening the existing file rather than deleting it and starting afresh...

    merely at clientco for the entertainment

    Comment


      #3
      As I recall, with UNIX, FTP put overwrites the file (same behaviour as cp/copy). Which OS is this, and is it built-in FTP or 3rd party?

      Comment


        #4
        Originally posted by woody1 View Post
        As I recall, with UNIX, FTP put overwrites the file (same behaviour as cp/copy). Which OS is this, and is it built-in FTP or 3rd party?
        It’s going from Windows to UNIX, using built-in FTP.
        …Maybe we ain’t that young anymore

        Comment


          #5
          Make sure that you're using binary mode to transfer the file. If you use ASCII mode, Windows and Unix handle line breaks differently (CR+LF on Windows, LF only on Unix). I haven't seen it cause this particular issue, but I have seen it cause corrupted files before.

          Comment


            #6
            Originally posted by WTFH View Post

            It’s going from Windows to UNIX, using built-in FTP.
            Weird. Never seen this before, nor could I find this issue with Google.

            As an experiment, it might be worth changing mode (binary/ascii) to see if this changes the behaviour.

            -----------

            I'd also use od (-a or -c) to examine the file on the UNIX side to see if there's anything odd around row 50.
            Last edited by woody1; 11 July 2024, 06:32.

            Comment


              #7
              Originally posted by woody1 View Post

              Weird. Never seen this before, nor could I find this issue with Google.

              As an experiment, it might be worth changing mode (binary/ascii) to see if this changes the behaviour.

              -----------

              I'd also use od (-a or -c) to examine the file on the UNIX side to see if there's anything odd around row 50.
              No, nothing special around row 50 - we've tried with other file sizes and it is just overwriting the new data as far as it needs to in the file.
              The people that the data is going to have now discovered that the new file has its original header and the new header as well.
              I wonder if we can send a Delete before we send the next file, or maybe move/rename the previous file when we send the new one.

              …Maybe we ain’t that young anymore

              Comment


                #8
                FTP rename for old file
                FTP send for new file
                Down with racism. Long live miscegenation!

                Comment


                  #9
                  Originally posted by WTFH View Post

                  No, nothing special around row 50 - we've tried with other file sizes and it is just overwriting the new data as far as it needs to in the file.
                  The people that the data is going to have now discovered that the new file has its original header and the new header as well.
                  Even more bizarre. I can't imagine it being an FTP server configuration option because who would want this behaviour.

                  Which UNIX is it? Sun, HP, Linux?

                  Comment


                    #10
                    Not seen this before. I wonder if it's the windows client 'restarting' the file transfer. TBH though, knowingly overwriting a file is bad practice operationally. If you think you might need it, make a backup, if you don't remove it as soon as it's done. Either of those are trivial using cron.
                    And the lord said unto John; "come forth and receive eternal life." But John came fifth and won a toaster.

                    Comment

                    Working...
                    X