I am using cURL to try to download all files in a certain directory.
here's what my list of files looks like:
I have tried to do in bash script: iiumlabs.[].csv.pgp
and iiumlabs*
and I guess curl is not big on wildcards.
curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
question: how do i download this directory of files using cURL?
You can use script like this for mac:
Here is how I did to download quickly with cURL (I'm not sure how many files it can download though) :
Why skip=2 ? To get ride of
.
and..
Why delims= ? To support names with spaces
What about something like this:
OK, considering that you are using Windows, the most simple way to do that is to use the standard
ftp
tool bundled with it. I base the following solution on Windows XP, hoping it'll work as well (or with minor modifications) on other versions.First of all, you need to create a batch (script) file for the
ftp
program, containing instructions for it. Name it as you want, and put into it:The first line opens a connection to the ftp server at
ftp.myftpsite.com
. The two following lines specify the login, and the password which ftp will ask for (replacelogin
andpass
with just the login and password, without any keywords). Then, you usemget *
to get all files. Instead of the*
, you can use any wildcard. Finally, you usequit
to close theftp
program without interactive prompt.If you needed to enter some directory first, add a
cd
command beforemget
. It should be pretty straightforward.Finally, write that file and run
ftp
like this:where
-i
disables interactivity (asking before downloading files), and-s
specifies path to the script you created.Sadly, file transfer over SSH is not natively supported in Windows. But for that case, you'd probably want to use PuTTy tools anyway. The one of particular interest for this case would be
pscp
which is practically the PuTTy counter-part of the opensshscp
command.The syntax is similar to
copy
command, and it supports wildcards:If you authenticate using a key file, you should pass it using
-i path-to-key-file
. If you use password,-pw pass
. It can also reuse sessions saved using PuTTy, using the load-load your-session-name
argument.If you're not bound to curl, you might want to use wget in recursive mode but restricting it to one level of recursion, try the following;
--no-parent
: Do not ever ascend to the parent directory when retrieving recursively.--level=depth
: Specify recursion maximum depth level depth. The default maximum depth is five layers.--no-directories
: Do not create a hierarchy of directories when retrieving recursively.Oh, I have just the thing you need!
and functions
isFtpUp
andsaveFtpFile
are as follows:EDIT:
it's a php script. save it as a .php file, put it on your webserver, change $ip to address(need not be ip) of ftp server you want to download files from, create a directory named downloadedFiles on the same directory as this file.