cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: automated ftp

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 13 Oct 2010 14:37:45 -0700

On Wed, Oct 13, 2010 at 01:00:47PM +0200, Goran Pivac wrote:
> Hello,
> I started using curl because i need to switch all my ftp transfers to ftp/ssl.
> Everything works fine (ssl and auth with certificates), but there is a
> problem with
> automated jobs using curl!
>
> I run ftp in many shell scripts and it looks something like this:
>
> ftp username_at_server.com < ftp.in
>
> where
>
> ftp.in looks like this:
> cd /input
> lcd /input
> put input.file1
> get output.file2
> ls
> cd /output
> lcd /output
> get result.file
> mkdir /new
> put result.file2
> ls
> quit
>
> Is there a way to call curl in the same manner?

curl is not an interactive program and uses a different means to specify
which files to upload and download. It supports the --config option which
takes options from a file, so in that sense you can call curl in the same
manner. But the contents of the file will be completely different.

> Something like this:
> curl --cert /certs/username.pem --cacert /certs/server.pem --ssl-reqd
> -u username: -inputfile ftp.in ftp://server.com
> or
> curl --cert /certs/username.pem --cacert /certs/server.pem --ssl-reqd
> -u username: ftp://server.com < ftp.in

That's not how curl works. It operates on URLs, so rather than manually
changing directories and pushing and pulling files, you just specify
the URLs and curl will do all the cd and mkdir commands automatically for
you.

> All I could find is:
> curl --cert /certs/username.pem --cacert /certs/server.pem --ssl-reqd
> -u username: -T /input/input.file1 ftp://server.com//input/
> when I want to upload
> and
> curl --cert /certs/username.pem --cacert /certs/server.pem --ssl-reqd
> -u username: -o /output/result.file
> ftp://server.com//output/result.file
> when I want to download,
> but that would mean i have to significantly alter my scripts and there
> are many of them!!

That's how curl works, so if you want to switch tools, you'll have to rewrite
your scripts. It should be pretty simple to automate a conversion from the
style you're using to curl's style, though. Another alternative is to use
an SSL-enabled ftp client, like the one in Linux Netkit. That might even
be plug-and-play compatible with your scripts as written.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-10-13