ftp - File Transfer Program, Transfers files between hosts.

ftp [-inegvd] [host]

There are many versions of FTP.          Windows ftp
All support
get, put, dele, ls, cd, status, binary, ASCII.
This is a rather complete description of the BSD implementation.

Invoked with a host name, ftp prompts for the

If invoked without a hostname, a command is prompted for(It is usually best to use open as the first command in this case).

Options specified at the command line
-i Turns off interactive prompting during multiple file transfers.
        For example: mput file001?
        Responding y puts the file, q quits putting,
        other responses skip to the next file in the match.
-n suppress .netrc processing, otherwise
        ftp reads the .netrc file in the user's home directory for an entry describing a
        username, password, account and macro definitions for the remote host.
-e Disables command editing and history support, if it was compiled into the ftp executable.
-g Disables file name globbing.
-v Verbose shows all responses from the remote host,
    as well as report on data transfer statistics.
-d Enable debugging of commands with addition detail displays.

open host [ port ] Open a connection to host . An optional port number may be supplied. If the auto-login option is on (default), ftp will also attempt to automatically log the user in.
close
disconnect
quit
bye
Terminate the FTP session with the remote host, and return to the command interpreter. Defined macros are erased.
user user-name [password] [account] Identify to the remote host.
  • If password is not specified and the host requires it, the user will be promped for it (after disabling local echo).
  • If account is not specified, and the host requires it, the user will be prompted for it.

Some hosts (like source file or documentation repositories) permit users without specific authorization to get and even put files. This is called anonymous ftp. The username used is anonymous and the pasword is your emailaddress.

account [acct-code] Supply a supplemental acct-code if used by a remote system .
binary
image
no changes are made to file contents, a MUST for non plain text files(images, .DOCs).
ASCII Files are considered to be plain text. Line terminaters will be corrected to be appropriate for the receiving system. Default type.
cr Toggle carriage return stripping during ascii type file retrieval.
Records are denoted by a carriage return/linefeed sequence during ascii type file transfer. When cr is on (the default), carriage returns are stripped from this sequence to conform with the UNIX single linefeed record delimiter, if the remote system is a unix system.
Records on non-UNIX remote systems may contain single line feeds; when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when cr is off.
type [type-name] Display or Set the file transfer type to ASCII(default), EBCDIC, image, tenex
cd rmt-directoryChange the working directory on the remote host
lcd [local-directory] Change the working directory on the local host to local-directory
cdup Change the remote directory up to the its parent
pwd Print the current Working Directory on the remote host.
mkdir rmt-directory Make rmt-directory.
To make a local directory, escape to a command shell using !mkdir local-directory.
rmdir rmt-directory remove rmt-directory
get rmt-file [local-file]
recv
If local-file is not specified, it is given the same name, *
reget rmt–file [local–file] get, except that if local-file exists and is smaller than rmt-file, local-file is presumed to be a partially transferred copy of remote-file and the transfer is continued from the apparent point of failure.
newer file‑name [local‑file] get file‑-name if the modification time of the remote file is more recent that the file on the local host or if the local file does not exist.
mget rmt-files
Expand wild carded rmt-files and do a get for each file, prompting if enabled.
See glob for details on the filename expansion.
put local-file [rmt-file]
send
If rmt-file is unspecified, the local-file name is used . *
mput local-files Expand wild carded local-files and put them.
See glob for details of filename expansion.
append local‑file [rmt‑file] If rmt‑file is left unspecified, the local‑file name is used in naming the remote file*.
rename [from] [to] Rename the file from on the remote host, to the file to.
delete rmt‑file
mdelete [rmt-files] Multiple Delete using wild card remote-files
ls [rmt-directory] [local‑file] List the current working directory or rmt‑directory. including any system-dependent information ; for example, most UNIX systems will produce output from the command ls -l. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local‑file for receiving ls output.
If no local file is specified, or if local‑file is -, the output is sent to the terminal.
dir [rmt‑directory] [local-file] Display a listing of the current working directory or rmt-directory outputting it to local-file or the terminal. If interactive prompting is on, ftp will prompt the user to verify that the last argument is the target local file for receiving dir output.
If local-file is - , output comes to the terminal.
modtime rmt-file Show the last modification time of the file on the remote host.
mdir rmt-files local-file Multiple dir remote files outout to local-file. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving mdir output.
nlist [rmt-directory] [local-file] list the filenames current working directory or remote-directory
mls rmt-files local-file Like nlist, except multiple rmt-files may be specified, and the local-file must be specified. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving mls output.
size rmt-file Return size of rmt-file
hash Toggle hash-sign (#) display for each 1024 byte data block transferred.
tick Toggle tick-mark (') display
glob Toggle filename expansion for mdelete, mget and mput.
Globbing for mput is done as in csh (i.e. *
If globbing is off , the file name arguments are taken literally and not expanded.
For mdelete and mget, each remote file name is expanded separately on the remote host and the lists are not merged.
Expansion of a directory name is likely to be different from expansion of the name of an ordinary file: the result depends on the remote operating system and ftp host, and can be previewed by doing mls rmt-files
Note: mget and mput are not meant to transfer entire directory subtrees of files. That can be done by transferring a tar archive of the subtree (in binary mode), which requires command access on the remote-system to extract the files after the transfer.
prompt Toggle interactive prompting. During multiple file transfers allowng the user to selectively retrieve files. If prompting is turned off (default is on), mget or mput will transfer all matching files, and mdelete will delete all matching files without asking the user.
help [command]
?
Displays a list of commands or an informative message about the meaning of command.
rhelp [command]
remote help
Displays a list of commands or an informative message about the meaning of command as per the remote host.
status Show the current status of ftp.
Connected to Real-World-Systems.com.
No proxy connection.
Mode: stream; Type: ascii; Form: non-print; Structure: file
Verbose: on; Bell: off; Prompting: on; Globbing: on
Store unique: off; Receive unique: off
Case: off; CR stripping: on   Ntrans: off      Nmap: off
Hash mark printing: off; Use of PORT cmds: on
Tick counter printing: off
Macros:
 birddata
 init
Remote system type is UNIX.
Using binary mode to transfer files.
remotestatus [file-name]
rstatus
With no arguments, show status of remote host.
When file-name is specified, show status of file-name on remote host.
system Show the operating system running on the remote host.
idle [seconds] Most remote hosts will disconnect if there is no activity after a number of seconds. Some permit setting the timeout.
chmod mode file-name Change the permission modes of file-name using rwxrwxrwx format for user:group:others format.
umask [newmask] Set the default umask on the remote host to newmask. Files will be created with these permissions.
! [command [args]] Invoke an interactive shell on the local host.
macdef macro-name Define the macro as macro-name .
A null line terminates macro input mode.
A $ followed by a number is replaced by the corresponding argument on the macro invocation line.
$i causes the macro to loop. On the first pass $i is replaced by the first argument on the macro invocation command line, on the second pass it is replaced by the second argument, and so on.
Use \ to prevent special treatment of $.
Macro definitions are cleared when close is executed.
$ macro-name [args] Execute the macro defined with the macdef command (perhaps in the .netrc file). Arguments are passed to the macro unglobbed.
runique Toggle receiving unique filenames.
Helpful when get is used without specifying a local filename. If a file already exists a ".1" is appended to the name. If that filename exsts, a ".2" appended … . after ".99", an error message is printed, and the transfer does not take place.
runique will not affect local files generated from a shell command .
The default is off.
sunique Toggle storing of files on remote under unique file names. Helpful when pt is used without specifying a remote filename. Default off.Remote ftp host must support ftp protocol STOU command for successful completion.
case Toggle file name case mapping during mget . When case is on (default is off), remote computer file names with all letters in upper case are written in the local directory with the letters mapped to lower case.
ntrans [inchars [outchars]] Set or unset the filename character translation mechanism.
This command is useful when connecting to a remote computer with different file naming conventions.

If no arguments are specified, the filename character translation mechanism is unset.

If arguments are specified, characters in remote filenames are translated during mput and put issued without a specified remote target filename, characters in local filenames are translated during mget and get commands issued without a specified local target filename.
Characters in a filename matching a character in inchars are replaced with the corresponding character in outchars.
If the characters position in inchars is longer than the length of outchars, the character is deleted from the file name. example:

ntrans . _
causes DOTs in a filename to be changed to underscores.
nmap [inpattern outpattern] Set or unset the filename mapping mechanism.
This command is useful when connecting to a remote computer with different file naming conventions or practices.

If no arguments are specified, the filename mapping mechanism is unset.

If arguments are specified, remote filenames are mapped during mput and put issued without a specified remote target filename and
local filenames are mapped during mget and get issued without a specified local target filename.

Inpattern is a template for incoming filenames (already processed according to ntrans and case).
Variable templating is accomplished by including the sequences $1, $2, …, $9 in inpattern.
Use \ to prevent this special treatment of the $ character. All other characters are treated literally, and are used to determine the nmap inpattern variable values.
For example, given inpattern $1.$2 and the remote file name "my.data",
$1 would have the value "my", and $2 would have the value "data".
The outpattern determines the resulting mapped filename. The sequences $1, $2, ...., $9 are replaced by any value resulting from the inpattern template. The sequence $0 is replace by the original filename.
The sequence [seq1, seq2] is replaced by [seq1] if seq1 is not a null string; otherwise it is replaced by seq2.
For example:

nmap $1.$2.$3 [$1,$2].[$2,file]
For input filename "myfile.data" would yield the output filename "myfile.data" For input filename "myfile.data.old" produces "myfile" "myfile.file" . For input filename ".myfile". "myfile.myfile"
Spaces may be included in outpattern, as in the example:
nmap $1 sed "s/ *$//" > $1
Use \ to prevent special treatment of the $, [, [, and , characters.
proxy ftp-command Execute ftp-command on a secondary connection.
Allows connection to two remote ftp hosts for transferring files between them.
After opening one server,
the first proxy command should be proxy open, to establish the secondary connection.
proxy open will not define new macros during the auto-login process.
proxy close will not clear macro definitions.
proxy get and proxy mget transfer files from the primary host to secondary host.
put, mput, and append transfer files from the host on the secondary connection to the host
Third party file transfers depend upon support of the ftp protocol PASV command by the host on the secondary control connection.
quote arg1 arg2 ... The arguments are sent, verbatim, to the remote host.
site arg1 arg2 ... The arguments are sent, verbatim, to the remote host as a SITE command.
reset Clear reply queue. This command re-synchronizes command/reply sequencing with the remote host.
restart marker get or put at the indicated marker. On UNIX systems, marker is a byte offset into the file.
sendport Toggle the use of PORT .
By default, ftp attempts to use a PORT command for each data transfer.
This can reduce delays when performing multiple file transfers. When disabled, no attempt will be made to use PORT commands for each data transfer. passive
bell after each file transfer command is completed.
verbose Toggle verbose mode. In verbose mode, responses from the FTP host are displayed as well as statistics regarding the efficiency of the transfer . By default, verbose is on.
trace Toggle packet tracing.
debug [debug-value] Toggle debugging mode. If an optional debug-value is specified it is used to set the debugging level. When debugging is on, ftp prints each command sent to the remote host, preceded by the string -->

Command arguments which have embedded spaces may be quoted with quote " marks.

ABORTING A FILE TRANSFER

To abort a file transfer, use the terminal interrupt key (usually Ctrl-C).
Sending will be immediately halted.
Receiving will be aborted after the remote accepts the ABOR command which may take a while.

FILE NAME Rules

ENVIRONMENT

SHELL For default shell.

HOME default directory of .netrc

The .netrc file contains login information for various hosts and macro definitions associated with each host.
Macro definitions are terminated with a null line.

Permissions of .netrc must be set to no access for group and other, (since it contains pasword information), or ftp will ignore it.
Use chmod 600 .netrc to set the permissions.
If there is a macro named init defined for the host it will be executed at login.
If the host is accessable by different names ( for example ftp.host.com and host.com ), seperate .netrc entries must be used for each.
The provcessing of the .netrc can be supressed by using -n on the ftp command.

Example:


machine ftp.hicom.net login danmars password yousilly 
macdef init
       cd ../danmar
       cd public_html
       cd dandr

machine hicom.net login danmars password notreally
macdef init
       cd ../danmar
       cd public_html
       cd dandr

machine michael.rc.net login fnewaloy password guess
machine HilltopConservancy.org  login realger1 password dontbesilly
machine freddie.montclair.edu  login germand password iwonttel
machine real-world-systems.com  login realger1 password inthedocs
macdef init
       cd public_html

File name globbing

From man csh

Filename substitution

A pattern begins with ~ or contains *,?,[ or{ is replaced with an alphabetically sorted list of file names which match the pattern.

  • * matches any string of characters, including the null string.
  • ? matches any single character.
  • [...] matches any one of the list of characters enclosed.
    file[nN][aA][mM][eE]
  • - within a list seperates a pair of characters and specifies a range that matches any character lexically between the two. file-[0-9][0-9]
  • ~ expands to the invoker's home directory. A / should usually be the next character
    ~ at the beginning of a filename followed by a username is substituted by the home directory of that user ; thus ~ken might expand to/usr/ken and ~ken/chmach to/usr/ken/chmach.
    ~ followed by a character other than a letter or / or appears elsewhere than at the beginning is unchanged.
  • ^ negates pattern The sequence [^...] matches any single character not specified by the list and/or ranges
    An entire pattern can also be negated with^:
    > echo *
    bang crash crunch ouch
    > echo ^cr*
    bang ouch
    Do not negate patterns which do not use?,*, or[] or which use{} or ~.

  • The meta-notation a{b,c,d}e is a shorthand forabe ace ade.
    Left-to-right order is preserved:
    /usr/source/s1/{oldls,ls}.c expands to
    /usr/source/s1/oldls.c
    /usr/source/s1/ls.c
    .
    The results of matches are sorted separately at a low level to preserve this order:../{memo,*box} might expand to
    ../memo ../box ../mbox.
    (Note that memo was not sorted with the results of matching *box.)
    It is not an error when this construct expands to files which do not exist, but it is possible to get an error from a command to which the expanded list is passed.
    This construct may be nested.
    As a special case {,} and {} are unchanged.

It is an error for a glob-pattern containing*,?,[ or~, with or without ^, not to match any files. However, only one pattern in a list of glob-patterns must match a file (so that, e.g.,rm *.a *.c *.o would fail only if there were no files in the current directory ending in.a,.c, or.o), and if the nonomatch shell variable is set a pattern (or list of patterns) which matches nothing is left unchanged rather than causing an error.

/ and . at the beginning of a filename or immediately following a / must be matched explicitly.

See ftpd and RFC 959

BSD Linux NetKit (0.17) August 15, 1999


Windows ftp help

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuffer] [-b:asyncbuffers] [-w:win dowsize] [host]

  -v              Suppresses display of remote server responses.
  -n              Suppresses auto-login upon initial connection.
  -i              Turns off interactive prompting during multiple file transfers.
  -d              Enables debugging.
  -g              Disables filename globbing (see GLOB command).
  -s:filename     Specifies a text file containing FTP commands; 
                   the commands will automatically run after FTP starts.
  -a              Use any local interface when binding data connection.
  -A              login as anonymous.
  -x:send sockbuf SO_SNDBUF size default 8192.
  -r:recv sockbuf SO_RCVBUF size default 8192.
  -b:async count  async count default 3
  -w:windowsize   transfer buffer size default 65535.
  host            Specifies the host name or IP address of the remote host to connect to.

Notes:
  - mget and mput commands take y/n/q for yes/no/quit.
  - Use Control-C to abort commands.

See also: ncftp,sftp