Thursday, December 3, 2009

How to download directory using ftp or scp?

When you try to download a directory using ftp, it wont work properly. We need to some tricks to get it. Here is one of such kind.

Let "aaaa" be the directory you want to download from a remote machine(consider this directory also has lot of subdirectories).

Step 1) tar -cvf directory.tar aaaa
- This step will create a tar file "directory.tar" containing directory "aaaa" and it subdirectory.

Step 2) Now you can use the normal ftp or scp(I feel it better than ftp) to download this file to your local machine. The step results in having the directory.tar file in your local machine.

2.a) local machine> ftp remotemachine_ip
password in remote machine : xxxx
remote machine ftp> cd "path to the file to be downloaded"
remote machine ftp> mget directory.tar
directory.tar? give "y"

(or)
2.b) scp -r username@remotemachine_ip:"path to the tarfile in remote machine" "path in local machine where you need the file"
password in remote machine:yyyy

step 3) In your local machine, untar the tar file. You will have what you need.
tar -xvf directory.tar

No comments:

Post a Comment