lftp(1)

Sophisticated file transfer program

Section 1 lftp bookworm source

Description

lftp - Sophisticated file transfer program

[-d] [-e cmd] [-p port] [-u user[,pass]] [site]

This man page documents lftp version 4.8.1.

lftp is a file transfer program that allows sophisticated FTP, HTTP and other connections to other hosts. If site is specified then lftp will connect to that site otherwise a connection has to be established with the open command.

lftp can handle several file access methods - FTP, FTPS, HTTP, HTTPS, HFTP, FISH, SFTP and file (HTTPS and FTPS are only available when lftp is compiled with GNU TLS or OpenSSL library). You can specify the method to use in `open URL' command, e.g. `open http://www.us.kernel.org/pub/linux'. HFTP is ftp-over-http-proxy protocol. It can be used automatically instead of FTP if ftp:proxy is set to `http://proxy[:port]'. Fish is a protocol working over an ssh connection to a unix account. SFtp is a protocol implemented in SSH2 as SFTP subsystem.

Besides FTP-like protocols, lftp has support for BitTorrent protocol as `torrent' command. Seeding is also supported.

Every operation in lftp is reliable, that is any non-fatal error is handled properly and the operation is repeated. So if downloading breaks, it will be restarted from the point automatically. Even if FTP server does not support the REST command, lftp will try to retrieve the file from the very beginning until the file is transferred completely.

lftp has shell-like command syntax allowing you to launch several commands in parallel in background (&). It is also possible to group commands within () and execute them in background. All background jobs are executed in the same single process. You can bring a foreground job to background with ^Z (c-z) and back with command `wait' (or `fg' which is alias to `wait'). To list running jobs, use command `jobs'. Some commands allow redirecting their output (cat, ls, ...) to file or via pipe to external command. Commands can be executed conditionally based on termination status of previous command (&&, ||).

If you exit lftp before all jobs are not finished yet, lftp will move itself to nohup mode in background. The same thing happens with a real modem hangup or when you close an xterm.

lftp has built-in mirror which can download or update a whole directory tree. There is also reverse mirror (mirror -R) which uploads or updates a directory tree on server. Mirror can also synchronize directories between two remote servers, using FXP if available.

There is command `at' to launch a job at specified time in current context, command `queue' to queue commands for sequential execution for current server, and much more.

On startup, lftp executes /etc/lftp.conf and then ~/.lftprc and ~/.lftp/rc (or ~/.config/lftp/rc if ~/.lftp does not exist). You can place aliases and `set' commands there. Some people prefer to see full protocol debug, use `debug' to turn the debug on. Use `debug 3' to see only greeting messages and error messages.

lftp has a number of settable variables. You can use `set -a' to see all variables and their values or `set -d' to see list of defaults. Variable names can be abbreviated and prefix can be omitted unless the rest becomes ambiguous.

If lftp was compiled with OpenSSL (configure --with-openssl) it includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)

Launch shell or shell command.

!ls

To do a directory listing of the local host.

Define or undefine alias name. If value is omitted, the alias is undefined, else it takes the value value. If no argument is given the current aliases are listed.

alias dir ls -lF alias less zmore

Wait until the given time and execute given (optional) command. See also at(1).

Attach the terminal to specified backgrounded lftp process.

The bookmark command controls bookmarks.

Site names can be used in the open command directly as-is or in any command that accepts input URLs using the bm:site/path format.

l lx . add [] T{ add current place or given location to bookmarks and bind to given name T} del remove bookmark with name edit start editor on bookmarks file import import foreign bookmarks list list bookmarks (default)

The cache command controls local memory cache. The following subcommands are recognized:

l lx . stat print cache status (default) on|off turn on/off caching flush flush cache size lim set memory limit, -1 means unlimited expire Nx T{ set cache expiration time to N seconds (x=s) minutes (x=m) hours (x=h) or days (x=d) T}

cat outputs the remote file(s) to stdout. (See also more, zcat and zmore)

Change current remote directory. The previous remote directory is stored as `-'. You can do `cd -' to change the directory back. The previous directory for each site is also stored on disk, so you can do `open site; cd -' even after lftp restart.

Change permission mask on remote files. The mode can be an octal number or a symbolic mode (see chmod(1)).

l1 l lx . -c, --changes like verbose but report only when a change is made -f, --quiet suppress most error messages -v, --verbose output a diagnostic for every file processed -R, --recursive change files and directories recursively

Close idle connections. By default only with the current server, use -a to close all idle connections.

`cls' tries to retrieve information about specified files or directories and outputs the information according to format options. The difference between `ls' and `cls' is that `ls' requests the server to format file listing, and `cls' formats it itself, after retrieving all the needed information.

l1 l lx . -1 single-column output -a, --all show dot files -B, --basename show basename of files only --block-size=SIZ use SIZ-byte blocks -d, --directory T{ list directory entries instead of contents T} -F, --classify T{ append indicator (one of /@) to entries T} -h, --human-readable T{ print sizes in human readable format (e.g., 1K) T} --si T{ likewise, but use powers of 1000 not 1024 T} -k, --kilobytes T{ like --block-size=1024 T} -l, --long T{ use a long listing format T} -q, --quiet don't show status -s, --size print size of each file --filesize T{ if printing size, only print size for files T} -i, --nocase T{ case-insensitive pattern matching T} -I, --sortnocase T{ sort names case-insensitively T} -D, --dirsfirst T{ list directories first T} --sort=OPT T{ "name", "size", "date" T} -S sort by file size --user, --group, --perms, --date, --linkcount, --links show individual fields --time-style=STYLE T{ use specified time format T}

execute given command ignoring aliases.

Switch debugging to level or turn it off. Options:

l1 l lx . -T truncate output file -o redirect debug output to the file -c show message context -p show PID -t show timestamps

Summarize disk usage. Options:

l1 l lx . -a, --all T{ write counts for all files, not just directories T} --block-size=SIZ use SIZ-byte blocks -b, --bytes print size in bytes -c, --total produce a grand total -d, --max-depth=N T{ print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize T} -F, --files print number of files instead of sizes -h, --human-readable T{ print sizes in human readable format (e.g., 1K 234M 2G) T} -H, --si likewise, but use powers of 1000 not 1024 -k, --kilobytes like --block-size=1024 -m, --megabytes like --block-size=1048576 -S, --separate-dirs do not include size of subdirectories -s, --summarize display only a total for each argument --exclude=PAT exclude files that match PAT

Prints (echos) the given string to the display.

Retrieve remote file to a temporary location, run a local editor on it and upload the file back if changed. Options:

l1 l lx . -k keep the temporary file -o explicit temporary file location

without -f it executes given arguments as a command. With -f, arguments are transformed into a new command. The format can contain plain text and placeholders $0...$9 and $@, corresponding to the arguments.

exit will exit from lftp or move to background if there are active jobs. If no job is active, code is passed to operating system as lftp's termination status. If code is omitted, the exit code of last command is used.

`exit bg' forces moving to background when cmd:move-background is false. `exit top' makes top level `shell' (internal lftp command executor) terminate. `exit parent' terminates the parent shell when running a nested script. `exit kill' kills all numbered jobs before exiting. The options can be combined, e.g. `at 08:00 -- exit top kill &' kills all jobs and makes lftp exit at specified time.

Alias for `wait'.

List files in the directory (current directory by default) recursively. This can help with servers lacking ls -R support. You can redirect output of this command. Options:

l1 l lx . -d MD, --max-depth=MD specify maximum scan depth -l, --ls use long listing format

Obsolete. Use one of the following instead:

get ftp://... -o ftp://... get -O ftp://... file1 file2... put ftp://... mput ftp://.../* mget -O ftp://... ftp://.../*

or other combinations to get FXP transfer (directly between two FTP servers). lftp would fallback to plain copy (via client) if FXP transfer cannot be initiated or ftp:use-fxp is false.

Retrieve the remote file rfile and store it as the local file lfile. If -o is omitted, the file is stored to local file named as base name of rfile. You can get multiple files by specifying multiple instances of rfile (and -o lfile). Does not expand wildcards, use mget for that.

l lx . -c continue, reget -E delete source files after successful transfer -e delete target file before the transfer -a use ascii mode (binary is the default) -P N download N files in parallel -O T{ specifies base directory or URL where files should be placed T}

Examples:

get README get README -o debian.README get README README.mirrors get README -o debian.README README.mirrors -o debian.mirrors get README -o ftp://some.host.org/debian.README get README -o ftp://some.host.org/debian-dir/ \ \ (end slash is important)

Transfer a single file. Options:

l lx . -o T{ destination file name (default - basename of rfile) T} -c continue, reget -E T{ delete source files after successful transfer T} -a use ascii mode (binary is the default) -d create the directory of the target file --source-region= T{ transfer specified region of source file T} --target-position= T{ position in target file to write data at T}

Glob given patterns containing metacharacters and pass result to given command or return appropriate exit code.

l lx . -f plain files (default) -d directories -a all types --exist return zero exit code when the patterns expand to non-empty list --not-exist return zero exit code when the patterns expand to an empty list

Examples:

glob echo * glob --exist *.csv && echo "There are *.csv files"

[cmd]

Print help for cmd or if no cmd was specified print a list of available commands.

View or manipulate the command history. Optional argument cnt specifies the number of history lines to list, or "all" to list all entries. Options:

l1 l lx . -w Write history to file. -r Read history from file; appends to current history. -c Clear the history. -l List the history (default).

List running jobs. If job_no is specified, only list a job with that number. Options:

l lx . -v verbose, several -v increase verbosity -r list just one specified job without recursion

all|job_no

Delete specified job with job_no or all jobs. (For job_no see jobs)

ldir

Change current local directory ldir. The previous local directory is stored as `-'. You can do `lcd -' to change the directory back.

existing-file new-link

Make a hard/symbolic link to an existing file. Option -s selects creation of a symbolic link.

command

Run specified command with local directory file:// session instead of remote session. Examples:

local pwd local ls local mirror /dir1 /dir2

Print current working directory on local machine.

params

List remote files. You can redirect output of this command to file or via pipe to external command. By default, ls output is cached, to see new listing use

or

Gets selected files with expanded wildcards.

l lx . -c continue, reget. -d T{ create directories the same as file names and get the files into them instead of current directory. T} -E delete source files after successful transfer -e delete target file before the transfer -a use ascii mode (binary is the default) -P N download N files in parallel -O T{ specifies base directory or URL where files should be placed T}

Mirror specified source directory to the target directory.

By default the source is remote and the target is a local directory. When using -R, the source directory is local and the target is remote. If the target directory is omitted, base name of the source directory is used. If both directories are omitted, current local and remote directories are used.

The source and/or the target may be URLs pointing to directories.

If the target directory ends with a slash (except the root directory) then base name of the source directory is appended.

l1 l lx . -c, --continue T{ continue a mirror job if possible T} -e, --delete T{ delete files not present at the source T} --delete-excluded T{ delete files excluded at the target T} --delete-first T{ delete old files before transferring new ones T} --depth-first T{ descend into subdirectories before transferring files T} --scan-all-first T{ scan all directories recursively before transferring files T} -s, --allow-suid T{ set suid/sgid bits according to the source T} --allow-chown T{ try to set owner and group on files T} --ascii T{ use ascii mode transfers (implies --ignore-size) T} --ignore-time T{ ignore time when deciding whether to download T} --ignore-size T{ ignore size when deciding whether to download T} --only-missing T{ download only missing files T} --only-existing T{ download only files already existing at target T} -n, --only-newer T{ download only newer files (-c won't work) T} --upload-older T{ upload even files older than the target ones T} --transfer-all T{ transfer all files, even seemingly the same at the target site T} --no-empty-dirs T{ don't create empty directories (implies --depth-first) T} -r, --no-recursion T{ don't go to subdirectories T} --recursion=MODE T{ go to subdirectories on a condition T} --no-symlinks T{ don't create symbolic links T} -p, --no-perms T{ don't set file permissions T} --no-umask T{ don't apply umask to file modes T} -R, --reverse T{ reverse mirror (put files) T} -L, --dereference T{ download symbolic links as files T} --overwrite T{ overwrite plain files without removing them first T} --no-overwrite T{ remove and re-create plain files instead of overwriting T} -N, --newer-than=SPEC T{ download only files newer than specified time T} --older-than=SPEC T{ download only files older than specified time T} --size-range=RANGE T{ download only files with size in specified range T} -P, --parallel[=N] T{ download N files in parallel T} --use-pget[-n=N] T{ use pget to transfer every single file T} --on-change=CMD T{ execute the command if anything has been changed T} --loop T{ repeat mirror until no changes found T} -i RX, --include=RX T{ include matching files T} -x RX, --exclude=RX T{ exclude matching files T} -I GP, --include-glob=GP T{ include matching files T} -X GP, --exclude-glob=GP T{ exclude matching files T} --include-rx-from=FILE T{ T} --exclude-rx-from=FILE T{ T} --include-glob-from=FILE T{ T} --exclude-glob-from=FILE T{ load include/exclude patterns from the file, one per line T} -f FILE, --file=FILE T{ mirror a single file or globbed group (e.g. /path/to/*.txt) T} -F DIR, --directory=DIR T{ mirror a single directory or globbed group (e.g. /path/to/dir*) T} -O DIR, --target-directory=DIR T{ target base path or URL T} -v, --verbose[=level] T{ verbose operation T} --log=FILE T{ write lftp commands being executed to FILE T} --script=FILE T{ write lftp commands to FILE, but don't execute them T} --just-print, --dry-run T{ same as --script=- T} --max-errors=N T{ stop after this number of errors T} --skip-noaccess T{ don't try to transfer files with no read access. T} --use-cache T{ use cached directory listings T} --Remove-source-files T{ remove source files after transfer (use with caution) T} --Remove-source-dirs T{ remove source files and directories after transfer (use with caution). Top level directory is not removed if it's name ends with a slash. T} --Move T{ same as --Remove-source-dirs T} -a T{ same as --allow-chown --allow-suid --no-umask T}

RX is an extended regular expression, just like in egrep(1).

GP is a glob pattern, e.g. `*.zip'.

Include and exclude options can be specified multiple times. It means that a file or directory would be mirrored if it matches an include and does not match to excludes after the include, or does not match anything and the first check is exclude. Directories are matched with a slash appended.

Note that symbolic links are not created when uploading to remote server, because FTP protocol cannot do it. To upload files the links refer to, use `mirror -RL' command (treat symbolic links as files).

For options --newer-than and --older-than you can either specify a file or time specification like that used by at(1) command, e.g. `now-7days' or `week ago'. If you specify a file, then modification time of that file will be used.

Verbosity level can be selected using --verbose=level option or by several -v options, e.g. -vvv. Levels are:

0 - no output (default) 1 - print actions 2 - +print not deleted file names (when -e is not specified) 3 - +print directory names which are mirrored

--only-newer turns off file size comparison and uploads/downloads only newer files even if size is different. By default older files are transferred and replace newer ones.

--upload-older allows replacing newer remote files with older ones (when the target side is remote). Some remote back-ends cannot preserve timestamps so the default is to keep newer files.

Recursion mode can be one of `always', `never', `missing', `newer'. With the option `newer' mirror compares timestamps of directories and enters a directory only if it is older or missing on the target side. Be aware that when a file changes the directory timestamp may stay the same, so mirror won't process that directory.

The options --file and --directory may be used multiple times and even mixed provided that base directories of the paths are the same.

You can mirror between two servers if you specify URLs instead of directories. FXP is automatically used for transfers between FTP servers, if possible.

Some FTP servers hide dot-files by default (e.g. .htaccess), and show them only when LIST command is used with -a option. In such case try to use `set ftp:list-options -a'.

The recursion modes `newer' and `missing' conflict with --scan-all-first, --depth-first, --no-empty-dirs and setting mirror:no-empty-dirs=true.