Search code examples
ftpftp-client

FTP "get" file from directory


How I can use the ftp get file to specific directory?

For Example:

I can't do this (A):

ftp> get /var/apache/cgi-bin/test-cgi
local: ./var/apache/cgi-bin/test-cgi remote: /var/apache/cgi-bin/test-cgi
local: ./var/apache/cgi-bin/test-cgi: No such file or directory

I can do this (B):

ftp> cd /var/apache/cgi-bin/
ftp> get test-cgi

But :

I want directly get the file from directory (A)..

Please Help Me.

Thanks


Solution

  • You can do this:

    ftp> get /some/path/some/file FreddyFrog
    

    which will get /some/path/some/file and store it as FreddyFrog in your current local directory.

    Or this:

    ftp> get /some/path/some/file /local/path/filename
    

    which will fetch the remote file and write it in /local/path/filename

    Or you can do this:

    ftp> cd /var/apache/cgi-bin
    ftp> lcd /local/someplace
    ftp> get test-cgi
    

    which will change directory to /var/apache/cgi-bin on the remote machine, LOCALLY change directory to /local/someplace and then download test-cgi to your local directory you just set.

    The reason your command doesn't work, is because by default, FTP tries to download the remote file to the same name in the local filesystem, so it found the file you wanted but couldn't download it because the directory /var/apache/cgi-bin does not exist on your local machine and you had not told it anywhere else to save the file - whereas I did - I told it to save the file as FreddyFrog.