I know I can get to a FTP location by accessing:
open ftp://user:pass@my_ftp_server/my_file
This will download the file in the Downloads folder.
How can I tell FTP tp download the file to a specific location I want?
I am looking for something like:
open ftp://user:pass@my_ftp_server/my_file=/tmp/fileDownloadedFromFtp
Best Answer
Use
curl
instead ofopen
:-)curl 'ftp://user:pass@my_ftp_server/my_file' > '/tmp/fileDownloadedFromFtp'
curl -o '/tmp/fileDownloadedFromFtp' 'ftp://user:pass@my_ftp_server/my_file'
(cd /tmp && curl -O 'ftp://user:pass@my_ftp_server/my_file')
curl
by default dumps the received data on standard output, so the first option just uses output redirection to store it. The second option explicitely sets the target directory/name, the third changes to the target directory first and then hascurl
store the data into a file named the same way as on the source side.If you want to avoid that username/password are visible to other users by running
ps
(or by looking into your shell history)create a text file
.netrc
in your home directory with the following content (replacemy_ftp_server
,user
,pass
with the real values)run
chmod 600 ~/.netrc
curl -n ...