Using the lftp Command for File Transfers

The lftp command (available from the lftp APT package) can be used for file transfers using FTP, HTTP, and various secure protocols such as HTTPS and HFTP if a remote proxy is enabled. Two great features of this command are the ability to restart a stalled download in the middle of a file transfer, as well as to start and run multiple downloads in a single session (with job control).

For example, here is a simple session showing an HTTP retrieval from a remote computer running the Apache web server:

$ lftp

-rw-r—r— — poweredby.png lftp> get poweredby.png

1154 bytes transferred lftp> quit

The iftp command can also be used as a "traditional" FTP client, but with some interesting features:

$ lftp -u phudson


iftp [email protected]:~> cd /d2/isos/redhat/limbo cd ok, cwd=/d2/isos/redhat/iimbo iftp [email protected]:/d2/isos/redhat/iimbo> mget disc1 & [0] mget *disc1* &

iftp [email protected]:/d2/isos/redhat/iimbo> jobs [0] mget *disc1*

Niimbo-i3 8 6-disc1.iso' at 56436448 (8%) 1.08M/s eta:9m [Receiving data] iftp [email protected]:/d2/isos/redhat/iimbo> quit [1843] Moving to background to compiete transfers... $ ps aux | fgrep lftp phudson 1843 7.6 1.0 5456 2404 ? s 19:09 0:02 iftp

A username (and password) can be passed on the command line using the -u option. You can use this feature to reduce the amount of interactive typing required when retrieving remote files, as an aid when using iftp in shell scripts, and when retrieving files with iftp as a background process.

By using an ampersand (&), the retrieval is conducted in the background, as shown in the preceding example. The jobs command is then used to show current transfers. If one logs out of the session (using the quit command), the file transfer continues as a background process if it has not completed. (This is verified by using the ps command.)

The iftp client has many additional features that can make the job of transferring files easier than using other FTP clients.

Was this article helpful?

0 0

Post a comment