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
.Bashrc Syntax Error: Unexpected End of File
How to Manage Log Verbosity Inside a Shell Script
How to Import Environment Settings into My Perl Program
How to Fix Loading Plugins in Eclipse 3.5.1 on Linux
Installing Octave Package in Ubuntu
Bash Script to Run a Constant Number of Jobs in the Background
Zipping Without Creating Parent Folder
Nginx Loadbalancer Too Many Open Files
Comparing Numbers in Bash Scripting
Cross Compiling Linux Arm Kernel with New Driver Module
How to Break an Arbitrary Tcp/Ip Connection on Linux
Termios Vmin Vtime and Blocking/Non-Blocking Read Operations
C Calling Conventions and Passed Arguments
Arm Assembly "Retne" Instruction
Find Command to Find Files and Concatenate Them
Intellij Idea 2017.2 Can't Add Openjk 9 on Linux Mint 18
Fixing the Line-Endings in a Git Repository Using the '.Gitattributes' File