Monday, November 26, 2007

copy folders in sftp

[from http://www.cae.wisc.edu/site/public/?title=linux-sftp]
Recursive Copy

If you try to copy a folder using the get or mget commands, sftp will complain that it "Cannot download non-regular file: filename". This is because the basic sftp client doesn't allow for a recursive copy. However, the program scp will allow you to do this. The scp command will not allow you to see what's on the sftp server, so the files need to be located using the sftp client.

Note: the scp command is a Unix command, and needs to be run from the Unix prompt. NOT within the SFTP client.

Usage: scp user@host:remote-path local-path

scp is like the Unix command cp and should work similarly. To copy a file from your Unix home directory and put it in the working directory, use the following command:

scp @sftp.cae.wisc.edu:~/ ./

Where is your CAE username, and is the file you wish to copy. Enter your password when scp asks for it. scp works just like a get command in sftp.

To recursively copy files or directories from your CAE account, use the -r switch.

For example, to copy the entire directory "tutorial" from my CAE Unix home directory to the home directory on your machine, the following command would be used:

ComputerName:~ # scp -r username@sftp.cae.wisc.edu:~/tutorial ~/

Where username is your CAE username.

No comments: