Shell Script to check if writing has finished before SCP

I am writing a shell script on Solaris to check if the files on the Remote Host is done writing before transferring over to Local Host. I have done a skeleton, but there are certain parts I am not sure on how to do. I did a little reading on the commands to check file size, it is stat -c %s LogFiles.txt but I am not sure as to how to check it over in the Remote Host.

# Get File Size on Remote Host

sleep 5

# Get File Size on Remote Host Again


#Loop 5 times
for i in {1..5}
    if [ "$INITIALSIZE" -ne "$LATESTSIZE"]
        sleep 5
        # Get File Size on Remote Host
        scp -P 22 $id@$ip:$srcpath/\*.txt $destpath 


Assuming that your measurement for 'done' is "file size constant for 5 sec", you can simply use ssh as follows:

ssh user@remote.machine "command to execute"

this can be piped or set as variable on the local machine e.g. in your case:

latestsize=$( ssh user@remote.machine "<sizedeterminer> <file>" )

Passwordless login of course would skip the askpass problem. See point 3.3 in this manual or an example here.

Need Your Help

Where to catch exception in WebClient method?

json windows-phone-7 webclient

I'm developing app which connects to service and consume some JSON data. Consuming works great ( rocks) but I wonder where I should catch exception error annd show simple MessageBox? Tried ...

How to play audio from buffer in Android

android android-mediaplayer audio-streaming audiobuffer

I am trying to play audio from buffer which is streamed from android to android.