Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks.
(1) I would like to know any unix/Linux command to check EOF char in a file.
(2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time.

When using scp, which is a good choice, check the exit code of the scp command in $?. If it is 0, all should be well.

scp has been done by Machine A on Machine B. We never have access to machine A and we are unknown about the time in which machine A has scp/ftp the file on machine B. That is the situation

Is it possible they send you a checksum of the sent file you could compare after it has been transfered?

Maybe see if they can transfer the file under a temporary name, then they rename the file to the correct name after a complete transfer.

That's one answer that works.

Basically, there's NO WAY you can tell on the receiving machine if the entire file has been transferred successfully.

YOU DO NOT HAVE THAT INFORMATION!!!

(Sorry about the shouting, but too many people think they can "solve" this problem somehow. They CAN'T. It's like solving "a + b = 2" when you don't know either a or b - it's impossible.)

The ONLY way to know that the complete file has been successfully transferred is for the sender to send some signal that the sending is complete.

Renaming the file from a temp name is one very good way to send that signal. Just make sure the rename doesn't move the file from one file system to another.

1 Like