I'm trying to use a cURL command to download a file from an FTP server to a local drive on my computer. I've tried
I'm trying to download an xml file from a https server using curl on a Linux machine with Ubuntu 10.4.2 I am able to connect to the remote server with my username and password but the output is only 'Virtual user logged in'. Downloading file from FTP using cURL. I'm trying to use a cURL command to download a file from an FTP server to a local drive on my computer. Color me badd member dies. CURL stands for command Line URL and is a simple, yet powerful, command line utility that gives the ability to download content using a lightweight executable that provides cross-platform support. CURL is community supported and is often a packaged part of some *nix systems already.
curl 'ftp://myftpsite' --user name:password -Q 'CWD /users/myfolder/' -O 'myfile.raw'
But it returns an error that says:
curl: Remote file name has no length!
curl: try 'curl --help' or 'curl --manual' for more information
curl: (6) Could not resolve host: myfile.raw; No data record of requested type
curl: try 'curl --help' or 'curl --manual' for more information
curl: (6) Could not resolve host: myfile.raw; No data record of requested type
I've tried some other methods, but nothing seems to work.
Also, I'm not quite sure how to specify which folder I want the file to be downloaded to. How would I do that?
![Using Using](/uploads/1/2/6/3/126306186/503542327.jpg)
studiohack♦
JosiahJosiah
migrated from stackoverflow.comMar 31 '11 at 21:34
This question came from our site for professional and enthusiast programmers.
4 Answers
Try
In FTP URLs, the path is relative to the starting directory (usually your homedir). You need to specify an absolute path, and that means using
%2f
to specify /
. This is needed because the path in ftp:
URLs is treated as a list of slash-separated names, each of which is supposed to be given to a separate CWD
command. The %2f
is decoded after splitting. See RFC 1738 and FTP URLs.As for the output location, just give a path to
-o
.Security suggestions:
- Download game wrc untuk android. Don't put your password in the URL. Storing it in
~/.netrc
is not particularly secure either, but it at least is hidden fromps -ef
. - Your password is sent in clear text. If the server supports it, use
curl --ssl-reqd
orcurl ftps://mysite/..
- Using SFTP (the SSH file transfer protocol) would be even better.
grawitygrawity
cUrly StoogecUrly Stooge
yan
How To Download A File
As yan suggests,
curl 'ftp://user:password@myftpsite/users/myfolder/myfile.raw'
should work, but some FTP servers use security policies that are not standards-compliant. In those cases, the
--ftp-method singlecwd
or --ftp-method nocwd
option may help.DanDan