"Linux Gazette...making Linux just a little more fun!"

Comfortable FTP

by Larry Ayers


There are quite a few FTP clients available for Linux these days. Several of them are X programs, but why incur the overhead of running an X FTP client? Downloading a file is not a very interactive process. Usually an FTP download is a process running in the background, which just needs to be checked every now and then.

On the other hand, using the basic command-line FTP program is not much fun unless you enjoy typing complete pathnames and filenames. A great improvement is the classic ncurses-based client NcFtp, written by Mike Gleason. This program has a well-designed bookmarking facility and supports the FTP "reget" command, which allows resumption of interrupted downloads. Unfortunately, file and directory names still must be typed in, though NcFtp does support shell-like completion of filenames in both local and remote directories.

Recently I came across a new FTP client called cftp. It is being developed by Dieter Baron, and though it is still a relatively new program, it has been working superbly for me.

About cftp

Cfpt isn't a showy application. It uses the termcap library, which allows it to show a reverse-video modeline displaying the current host and directory, as well as the number of bytes transferred. Otherwise it resembles a ls -l listing of files in the remote directory. The default keybindings are fairly intuitive: d downloads a file, v views a remote file using your default pager, and the left and right arrow keys function like they do in the Lynx text-mode web-browser: the left arrow-key takes you back to the previous directory, and the right arrow-key descends into the subdirectory under the cursor. The other key-bindings (as well as user options) can be viewed during a session by typing :help. The colon as a prefix to a command will be familiar to anyone who has used the vi editor or one its clones. Vi and Emacs motion-keys can also be used instead of the arrow-keys.

What impressed me was the quickness with which the program starts up and makes the connection; before you know it a directory listing is displayed. This is a small and efficient little program which nevertheless has convenient keyboard commands. It's just the thing for making a quick check of an FTP site, perhaps reading a few *.lsm or README files, then pressing q which tells cftp to first log off, then quit. Directory listings displayed during a session are cached in memory, so returning to a previously-viewed directory is near-instantaneous.

Many FTP programs are in effect front-ends for the command-line FTP utility, just as many mail clients use sendmail to do the actual mail-handling. In contrast, cftp uses its own built-in FTP routines; this may be one reason for its speed. Instead of passing an FTP command through a GUI layer before handing it to the actual FTP executable, cftp is talking directly with the remote server.

Aliases and Configuration

There are two files which cftp reads when starting up, ~/.cftprc and ~/.netrc. The ~/.cftprc file can contain personal changes to default settings, such as keybindings. Aliases for oft-visited sites can be entered into this file as well. The line

alias sun ftp://sunsite.unc.edu/pub/Linux/Incoming

enables quick access to the site by merely typing cftp sun.

The ~/.netrc file is used by the default FTP program, as well as the FTP facilities provided by GNU Emacs' dired and XEmacs' EFS. Cftp refers to this file as well. An entry like this:

default login anonymous password [your e-mail address]

will save typing login info for sites which allow anonymous access, and if you access a site for which you have a username and password, lines like these:

machine [hostname] login [login-id] password [password]
macdef init cd /[directory to change to]

will speed up accessing the site.

New Enhancements

When I began this review version 0.7 was the latest version; since then version 0.8 has been released, which contains several new features:


As I write this cftp-0.8.tar.gz is the current version; the latest release can be found at the cftp home FTP site, or via the WWW at this site.

I enjoyed trying this small application and find myself using it often. It's a small download and should compile easily if you have libtermcap installed. If you do try it, let Deiter Baron know what you think of it.

Copyright © 1997, Larry Ayers
Published in Issue 23 of Linux Gazette, December 1997