ThingyMaJig

Thingy Ma Jig is the blog of Nicholas Thompson and contains any useful tips, sites and general blog-stuff which are considered interesting or handy!

Connect

LinkedIn GitHub

Topics

announcement 25 apache 3 Apple 1 bash 8 code 7 cool 30 Days Out 8 Dark Basic Pro 4 design 12 doctor who 1 Drupal 74 E4600 1 EOS 400D 3 firefox 2 Flickr 3 free 21 games 5 geek 38 git 2 GreaseMonkey 1 hardware 7 Homebrew 1 How to 37 humour 5 iphone 1 javascript 1 jquery 1 K800i 6 k850i 4 lighttpd 3 linux 33 mac 9 miscellaneous 4 mobile phone 9 music 4 mysql 8 n73 1 n95 1 New Relic 1 Ogre3D 1 OS X 2 performance 3 photos 10 programming 40 Quicksilver 1 review 19 security 3 SEO 6 software 12 svn 2 technology 4 tip 7 tips 10 tv 3 video 3 vim 7 webdev 2 websites 33 wii 1 windows 1 YADS 10

YAFC as an FTP Client

Posted on 02 February 2007 in
review linux How to

Firstly - YAFC? "What on earth is YAFC?" I hear you say. YAFC is a command line FTP tool which, unfortunately, only comes in source code which means you need to know how to compile it. Fortunately, compiling it is easy - it required very few dependencies and most of those I could install using yum on my linux box (Redhat Fedora).

The main reason I chose to use YAFC over something like the built in FTP client was due to its ability to recursively FTP contents. As part of my day job, I had to transfer an entire website from a shared host (with XCalibre) to our company dedicated server (hosted by Rackspace). Unfortunately, the shared server didn't allow shell access so there was no way I could make a compressed tarball of the site which would have made my life a lot easier. On top of this, the site was many levels deep with folders within folders within folders! This would have made FTP without recursion a nightmare. Transferring it in-house with a GUI client like FileZilla and then back out again would have taken hours due to the site's size… This is where YAFC stepped in!

YAFC - the shell friendly ftp client!

[adsense:120x600:8582050831]

As the site was huge and the process was going to take a while, my first step was to use the screen command to open up a new 'virtual window'. Once the process was started I could detach this window (and even disconnect from the server altogether) and the process would continue to run in a detached screen which I could then re-attch at a later time by executing screen -r (or, if there were multiple detached screen's, I could list them by screen -list and then reattach using the ID from the list after the '-r' argument, eg screen -r 8715). Screen is one of the most useful linux commands I have found!

At this new screen, I connected to the server by issuing the command in this form (details have been changed for privacy reasons):

yafc ftp://joebloggs@myserver.com

YAFC then connects to the server and authenticates (if necessary). I then executed the command get -r * which tells YAFC to get all files and folders recursively off the remote server. You can replace get with put if you want to upload rather than download.

Once this was going - I pressed Ctrl and A together, then the d key on its own - this is the keyboard combination to detach a screen. I then clossed the Putty window and got on with some other work for an hour or so. I logged back in later on and retrieved the screen using the above retrieval code (screen -r) and the entire site had transferred across flawlessly.

Today I have also found out (from the YAFC mailing list archive) that you can pass a text file with command in it to YAFC to execute. This is not an intentional feature, according to the author of this program, however it seems to work!

I used YAFC's bookmarking feature to store the login details to my backup server and now I can (in theory) use cron to automatically run YAFC to transfer my locally backed up files onto the remote server!

YAFC is one hell of a good (and lightweight) FTP Client and I'm glad I installed it.