Joho the Blog » Beginner-to-Beginner: FTP via curl
EverydayChaos
Everyday Chaos
Too Big to Know
Too Big to Know
Cluetrain 10th Anniversary edition
Cluetrain 10th Anniversary
Everything Is Miscellaneous
Everything Is Miscellaneous
Small Pieces cover
Small Pieces Loosely Joined
Cluetrain cover
Cluetrain Manifesto
My face
Speaker info
Who am I? (Blog Disclosure Form) Copy this link as RSS address Atom Feed

Beginner-to-Beginner: FTP via curl

Cyberduck works well for most of my FTP’ing needs. But sometimes I want to be able to automate an upload or a download without having to go through a graphical user interface. The Mac comes with a handy tool called curl. Unfortunately, I’ve had trouble finding instructions comprehensible to one such as I. (Here’s man page for curl. Of course, you can also see the man page by typing man curl into a terminal window. As usual, the man page is efficient to the point of being terrifying.) So, here’s a beginner-to-beginner guide. As always, use this carefully because I don’t know what I’m talking about.

To begin, open up a terminal window. Type curl -V into it and hit return just to make sure that curl is there. If it is, it should tell you what version of curl you’re running.

Excellent!


If you want to upload a file called test.txt to the mydir directory on your myserver server, and if your username is uname and your password is pwd, then you’d type the following into your terminal:

curl -v -T test.txt ftp://uname:pwd@myserver/mydir/

The -v turns on verbose mode so you can see all the errors I’ve made in these instructions. Once it works, you can replace the -v with -s to silence the messages.

If you want to download a file, use -O instead of -T.

If you want to do this by double clicking on a file in the Finder, you have to go through a few more steps.

First, type into a text editor the same line that you were typing into the terminal, except make sure that you give the full pathname of the file you want to upload. Save the file with .command as the extension (e.g., autoftp.command). In the terminal go the directory where you’ve saved the file and type chmod a+x autoftp.command. This makes the file executable (runnable). Now double clicking it in the Finder should run it.

There’s lots more you can do with curl. If you figure out how to do it let me know. And, of course, I’ll happily correct this post with the corrections you point out in the comments… [Tags: ]

Previous: « || Next: »

Leave a Reply

Comments (RSS).  RSS icon