There’s nothing quite as painful as watching large files
download over slow connections. And it’s even worse when it’s 9 PM, you’re the
only one left in the office, and you can’t leave until your entire file upload
or download is complete.
Fortunately, there is
a solution to this unhappy state of affairs. You can use the NcFTP suite of
file transfer tools to automate your file transfer, allowing you to go home,
catch a movie, have a good night’s sleep, and come back in the morning to find
your work complete.
Sounds too good to be true, doesn’t it? Keep reading, and
I’ll show you just how easy it is!
Step 1: Get NcFTP Client
Client is a suite of FTP client utilities that serve as replacements for
the standard UNIX ftp command. If you’re using Linux, you probably already have
these utilities – they come bundled with most popular distributions. You can
check for their presence by typing the following command at your shell prompt:
shell> type ncftpbatch
ncftpbatch is /usr/bin/ncftpbatch
If the ncftpbatch application
exists on your system, the command above will return the full path to it. If
you don’t receive this output, you’ll need to download and install the
application suite from http://www.ncftp.com/. Binary
archives are available for a wide variety of platforms, so you should have no
trouble finding one for yours; in case you do, you can always download the source code for the
suite and compile it yourself.
Step 2: Create one or more file transfer jobs
Once you’ve got NcFTP installed, the next step is to create
and submit a file transfer “job”. This job is essentially a
background task, which runs continually until the file transfer is complete. A
job can be created and submitted with the ncftpget and ncftpput utilities; use the former for automated file downloads and
the latter for automated file uploads. Here’s an example:
shell> ncftpget -bb -u joe -p secret ftp://ftp.example.com/pub/sources20050607.zip
+ Spooled; writing locally as ./sources20050607.zip.
This command creates a download job for the file sources20050607.zip. The -u and -p parameters
specify the username and password for the FTP server respectively, while the -bb parameter
tells ncftpget to place the
job in the background.
If it’s a file upload you’re after, use ncftpput instead, as in this next example:
shell> ncftpput -bb -u admin -p guessme ftp.example.com secure/client203 report.pdf
+ Spooled; sending remotely as secure/client203/report.pdf.
In this case, the access credentials must be followed by the
remote host name, the remote directory name, and the local path to the file
that is to be uploaded, respectively. Again, the -bb parameter
tells ncftpput to place the
job in the background.
Of course, all of this is just for a single file transfer.
If you have multiple files to be uploaded or downloaded, simply invoke ncftpput or ncftpget again, once
for each file, thereby creating a file transfer job for each file.
Step 3: Begin processing the jobs
Once all the jobs have been submitted, begin processing them
by invoking the ncftpbatch command, as
shell> ncftpbatch -d
This command will begin processing the jobs created in Step
2. Notice the -d
option to the command; this runs ncftpbatch as a daemon,
allowing you to continue working at the console while the jobs are being
processed. If work is the last thing on your mind, this is the point at which
you leave the office; ncftpbatch will process
all the submitted jobs automatically, with no intervention needed on your part.
The program also includes intelligence to automatically re-try jobs that fail,
either due to an error in connection or because the remote server is
You can obtain a list of current jobs at any time with the
command ncftpbatch -l. This will
display the jobs currently queued for processing. Here’s an example:
shell> ncftpbatch –l
—Scheduled-For—–Host—-Command——-2005-07-11 20:30 ftp.example.com GET sources20050607.zip
2005-07-11 20:31 ftp.example.com PUT report.pdf
Hopefully, using this tip will save you some time (and
mental anguish) the next time you have a bunch of files to transfer. Happy FTPing!