Using CURL to transfer files from a ftps server

Unfortunately Solaris does not come with a ftps compatible client by default, but you can get round this by either a) installing another client such as lftp or b) using CURL

CURL is not a super friendly program however, so here are some of my notes on using it to access one of my servers.

Get a directory listing of the files in the source directory

curl  -k -3 --ftp-ssl -u techie ftp://files.blah.com:990//export/home/sources/* -l

-k says to ignore certificate problems (this may be bad in the outside world – but this is all internal to my network and we don’t have ssl certificates)

-u specifies the username to connect to the server. You can optionally follow this with a : and a password -u username:password but this will be clear text. If you don’t specify a password on the command line it will prompt. Another option is to use a curl config file (–config with the username:password specified in it)

-3 says to use SSLv3 (this may not be relevant in your environment)

// in the directory path says that it is an absolute path not a relative one.

This will give you a list of the files inside the directory, which is super handy for scripting purposes.

Then you can issue curl command for each file you need to download  like

curl  -k -3 --ftp-ssl -u techie ftp://files.blah.com:990//export/home/sources/myfile.txt  -O

-O specifies to create the file in  your local directory, with the same filename.

Curl has a whole bunch of options and this is only a tiny snapshot. There is a really useful man page available online at http://curl.haxx.se/docs/manpage.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s