Scp: How to Find Out That Copying Was Finished

scp: how to find out that copying was finished

Off the top of my head, you could do something like:

touch tinyfile
scp bigfile tinyfile user@host:

Then when tinyfile appears you know that the transfer of bigfile is complete.

As pointed out in the comments, this assumes that scp will copy the files one by one, in the order specified. If you don't trust it, you could do them one by one explicitly:

scp bigfile user@host:
scp tinyfile user@host:

The disadvantage of this approach is that you would potentially have to authenticate twice. If this were an issue you could use something like ssh-agent.

Copying files from server to local computer using SSH

It depends on what your local OS is.

If your local OS is Unix-like, then try:

scp username@remoteHost:/remote/dir/file.txt /local/dir/

If your local OS is Windows ,then you should use pscp.exe utility.
For example, below command will download file.txt from remote to D: disk of local machine.

pscp.exe username@remoteHost:/remote/dir/file.txt d:\

It seems your Local OS is Unix, so try the former one.


For those who don't know what pscp.exe is and don't know where it is, you can always go to putty official website to download it. And then open a CMD prompt, go to the pscp.exe directory where you put it. Then execute the command as provided above

EDIT

if you are using Windows OS above Windows 10, then you can use scp directly from its terminal, just like how Unix-like OS does.
Thanks to @gijswijs @jaunt @icanfathom

best way to programmatically check for a failed scp in a shell script

Use $? to access the return value of the last command. Check the man page for scp to verify, but I think a return value of zero means success. A non-zero value means some kind of failure.



Related Topics



Leave a reply



Submit