Click here to Skip to main content
15,897,704 members
Articles / FTP

FTP Made Easy with LFTP

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
1 Nov 2015CPOL 7.3K  
This article describes how to use the LFTP client to easily perform FTP related tasks.

I was looking for a decent FTP client program to perform a relatively complex series of file transfers using a Linux shell script and came across LFTP.

LFTP is a freely available file transfer program which allows FTP, HTTP and a number of other connections to a remote host.

A few of the evaluation commands I tried with LFTP are listed here as a future reference to myself as well as anyone looking for quick examples.

The easiest method to connect to an FTP server using LFTP is to simply specify the URL of the host. It will open up a LFTP console which allows to perform multiple actions.

BAT
#Log into password protected FTP server
lftp -u <user name,[password]> <URL>
lftp -u myftp,mypassword 192.168.110.1

#Log into a FTP server as anonymous (if allowed)
lftp <URL>
lftp  192.168.110.1

#Once connected to the FTP server, LFTP console appears on Linux terminal.

#Create a directory
lftp <URL:/>mkdir <directory name>
lftp 192.168.110.1:/> mkdir music

#Upload a file
lftp <URL:/>put <file path>
lftp 192.168.110.1:/videos> put ./video.avi

#Download a file from FTP server
lftp <URL:/>get <file path>
ftp 192.168.110.1:/> get videos/video.avi

#Download a file from FTP server and place it in a specific local directory
lftp <URL:/>get <file path> -o <target local directory>
get videos/video.avi -o /tmp/downloads/

#List available files on a selected directory in FTP server
lftp <URL:/>ls
lftp 192.168.110.1:/> ls
drwxr-xr-x 1 ftp ftp              0 Jan 31 14:22 music
drwxr-xr-x 1 ftp ftp              0 Jan 31 14:22 videos

#Close connection
lftp 192.168.110.1:/> exit

Reference

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer MTT Network (Pvt.) Ltd.
Sri Lanka Sri Lanka
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --