FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
-------------------------------------------------------------------------------
ftp
PURPOSE
Transfers files between local and remote host.
SYNTAX
+--------+ +--------+
ftp ---| +----+ |---| |---|
+-| -d |-+ +- host -+
^| -g ||
|| -i ||
|| -n ||
|| -v ||
|+----+|
+------+
DESCRIPTION
The ftp command is the user interface to the ARPANET standard File Transfer
Protocol. The program allows a user to transfer files to and from a remote
network site.
Note: The user's shell on the remote machine must be listed in the
remote's /etc/shells file for ftp to work.
FLAGS
The ftp command options are:
-d Enables debugging.
-g Disables file name globbing.
-i Shuts off interactive prompting during multiple file transfers.
-n Restrains ftp from attempting auto login upon initial connection. If
auto login is enabled, ftp checks the .netrc file (see "The .netrc
File") in the user's home directory for an entry describing an account
on the remote machine. If no entry exists, ftp prompts for the remote
machine login name (default is the user identity on the local machine),
and, if necessary, prompts for a password and an account with which to
log in.
-v (verbose on)
Forces ftp to show all responses from the remote server, as well as
report on data transfer statistics. By default, verbose is set to
"off." To set verbose on, use the verbose sub-command.
Processed July 12, 1991 FTP(1c,C) 1
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
COMMANDS
The client host, which ftp is to communicate with, may be specified on the
command line. If this is done, ftp immediately attempts to establish a
connection to an FTP server on that host. Otherwise, ftp enters its command
interpreter and awaits instructions from the user. When ftp is awaiting
commands from the user, the prompt "ftp>" is provided to the user. The
following commands are recognized by ftp:
! [ command [ args ] ]
Invokes an interactive shell on the local machine. If
there are arguments, the first is taken to be a command to
execute directly, with the rest of the arguments as its
arguments.
$ macro-name [ args ]
Executes the macro macro-name that was defined with the
macdef command. Arguments are passed to the macro
unglobbed.
account [ passwd ] Supplies a supplemental password required by a remote
system for access to resources once a login has been
successfully completed. If no argument is included, the
user is prompted for an account password in a non-echoing
input mode.
append local-file [ remote-file ]
Appends a local file to a file on the remote machine. If
remote-file is left unspecified, the local file name is
used in naming the remote file after being altered by any
ntrans or nmap setting. File transfer uses the current
settings for type, format, mode, and structure.
ascii Sets the file transfer type to ASCII. This is the default
type.
bell Arranges for a bell to sound after each file transfer
command is completed.
binary Sets the file transfer type to support binary image
transfer. Binary image transfer should be used for all
binary files.
bye Terminates the FTP session with the remote server and exits
ftp. An end of file also terminates the session and exits
ftp.
case Toggles remote computer file name case mapping during mget
commands. 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.
Processed July 12, 1991 FTP(1c,C) 2
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
cd
Changes the remote machine working directory to dir as
indicated.
cdup Changes the remote machine working directory to the parent
of the current remote machine working directory.
close Terminates the ftp session with the remote server, and
returns to the command interpreter. Any defined macros are
erased.
cr Toggles 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 AIX single line feed
record delimiter. Records on non-AIX System/370 remote
systems may contain single linefeeds. When an ASCII-type
transfer is made, these linefeeds may be distinguished from
a record delimiter only when cr is off.
delete remote-file Deletes the file remote-file on the remote machine.
debug [ debug-value ]
Toggles the 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
machine, preceded by the string ("-->"). If the
debug-value is 0 debugging is off. If the debug-value is a
positive integer, debugging is on.
dir [remote-directory] [local-file] (2)
Prints a listing of the directory contents in the
directory, remote-directory and, optionally, placing the
output in local-file. If no directory is specified, the
current working directory on the remote machine is used.
If no local file is specified or local-file is (-), output
is displayed on the terminal.
disconnect Is a synonym for close.
form format Sets the file transfer form to format. The only supported
format is non-print. Only for use with ASCII and EBCDIC.
get remote-file [local-file] (2)
Retrieves the remote-file and stores it on the local
machine. If the local file name is not specified, it is
given the same name it has on the remote machine, subject
to alteration by the current case, ntrans, and nmap
settings. The current settings for type, form, mode, and
structure are used while transferring the file.
Processed July 12, 1991 FTP(1c,C) 3
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
glob Toggles file name expansion for mdelete, mget and mput. If
globbing is turned off with glob, the file name arguments
are taken literally and not expanded. Globbing for mput is
done as in csh. For mdelete and mget, each remote file
name is expanded separately on the remote machine 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 exact result depends on the foreign
operating system and ftp server, and can be previewed by
entering
mls remotefilename -
Note: mget and mput are not meant to transfer entire
directory subtrees of files. This can be done by
transferring a tar format archive file. Refer to AIX
Operating System Commands Reference.
hash Toggles hash-sign (#) printing for each data block
transferred. The size of a data block is 4096 bytes.
help [command] Prints an informative message about the meaning of command.
If no argument is given, ftp prints a list of the known
commands.
lcd [directory] Changes the working directory on the local machine. If no
directory is specified, the user's home directory is used.
ls [remote-directory [local-file] (2)
Prints an abbreviated listing of the contents of a
directory on the remote machine. If remote-directory is
left unspecified, the current working directory is used on
the remote machine. If no local file is specified, or if
local-file is -, the output is sent to the terminal.
Processed July 12, 1991 FTP(1c,C) 4
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
macdef macro-name Defines a macro. Subsequent lines are stored as the macro
macro-name. A null line (consecutive new line characters
in a file or carriage returns from the terminal) terminates
macro input mode. There is a limit of 16 macros and 4096
total characters in all defined macros. Macros remain
defined until a close command is executed. The macro
processor interprets $ and \ as special characters. A $
followed by a number (or numbers) is replaced by the
corresponding argument on the macro invocation command
line. A $ followed by an i signals the macro processor
that the executing macro is to be looped. 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. A \ followed
by any character is replaced by that character. Use the \
to prevent special treatment of the $.
mdelete [remote-files]
Deletes the remote-files on the remote machine.
mdir remote-files local-file (2)
Like dir, except multiple remote files may be specified.
If interactive prompting is on, ftp prompts the user to
verify that the last argument is indeed the target local
file for receiving mdir output.
mget remote-files (2)
Expands the remote-files on the remote machine and supplies
a get for each file name thus produced. See glob for
details on the file name expansion. Resulting file names
are then processed according to case, ntrans, and nmap
settings. Files are transferred into the local working
directory, which can be changed with lcd directory. New
local directories can be created with ! mkdir directory.
mkdir directory-name (1)
Makes a directory on the remote machine.
mls remote-files local-file (2)
Similar to ls, except multiple remote files may be
specified. If interactive prompting is on, ftp prompts the
user to verify that the last argument is indeed the target
local file for receiving mls output.
mode [mode-name] Sets the file transfer mode to mode-name. The only
supported mode is 'stream' mode.
Processed July 12, 1991 FTP(1c,C) 5
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
mput local-files (1)
Expands wild cards in the list of local files given as
arguments and supplies a put for each file in the resulting
list. See glob for details of file name expansion.
Resulting file names are then processed according to ntrans
and nmap settings.
nmap [inpattern [outpattern]
Sets or unsets the file name mapping mechanism. If no
arguments are specified, the file name mapping mechanism is
unset. If arguments are specified, remote file names are
mapped during mput commands and put commands issued without
a specified remote target file name. If arguments are
specified, local file names are mapped during mget commands
and get commands issued without a specified local target
file name. This command is useful when connecting to a
non-AIX System/370 remote computer with different file
naming conventions or practices.
The mapping follows the pattern set by inpattern and
outpattern. Inpattern is a template for incoming file
names (which may have already been processed according to
the ntrans and case settings). 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 mydata.data, $1 has the value mydata, and $2 has
the value data.
The outpattern determines the resulting mapped file name.
The sequences $1, $2, ...., $9 are replaced by any value
resulting from the inpattern template. The sequence $0 is
replaced by the original file name. Additionally, the
sequence [seq1,seq2] is replaced by seq1 if seq1 is not a
null string. Otherwise, it is replaced by seq2. For
example, the command nmap $1.$2.$3 [$1,$2]. [$2,file]
would yield the output file name myfile.data for input file
names myfile.data and myfile.data.old, myfile.file for the
input file name myfile, and myfile.myfile for the input
file name .myfile. Spaces may be included in outpattern,
as in the example:
nmap $1 |sed "s/ *$//" > $1 .
Use the \ character to prevent special treatment of the $,
[, ], and , characters.
Processed July 12, 1991 FTP(1c,C) 6
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
ntrans [inchars[outchars]
Sets or unsets the file name character translation
mechanism. If no arguments are specified, the file name
character translation mechanism is unset. If arguments are
specified, characters in remote file names are translated
during mput commands and put commands issued without a
specified remote target file name. If arguments are
specified, characters in local file names are translated
during mget commands and get commands issued without a
specified local target file name. This command is useful
when connecting to a non-AIX System/370 remote computer
with different file naming conventions or practices.
Characters in a file name matching a character in inchars
are replaced with the corresponding character in outchars.
If the character's position in inchars is longer than the
length of outchars, the character is deleted from the file
name.
open host [port] Establishes a connection to the specified host FTP server.
An optional port number may be supplied, in which case, ftp
attempts to contact an FTP server at that port. If the
auto login option is on (default), ftp also attempts to
automatically log the user in to the FTP server.
prompt Toggles interactive prompting. Interactive prompting
occurs during multiple file transfers to allow the user to
selectively retrieve or store files. If prompting is
turned off (default is on), any mget or mput transfers all
files, and any mdelete deletes all files.
proxy ftp-command Executes an ftp command on a secondary control connection.
This command allows simultaneous connection to two remote
ftp servers for transferring files between the two servers.
The first proxy command should be an open, to establish the
secondary control connection. Enter the command proxy ? to
see other ftp commands executable on the secondary
connection.
The following commands behave differently when prefaced by
proxy :
open Does not define new macros during the auto login
process.
close Does not erase existing macro definitions.
get, mget Transfers files from the host on the primary
control connection to the host on the secondary
control connection.
Processed July 12, 1991 FTP(1c,C) 7
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
put, mput, append (1)
Transfers files from the host on the secondary control
connection to the host on the primary control connection.
Third party file transfers depend upon support of the FTP
protocol PASV (passive) command by the server on the
secondary control connection.
put local-file [remote-file] (1)
Stores a local file on the remote machine. If remote-file
is left unspecified, the local file name is used after
processing according to any ntrans or nmap settings in
naming the remote file. File transfer uses the current
settings for type, format, mode, and structure.
pwd Prints the name of the current working directory on the
remote machine.
quit Exit ftp.
quote arg1 arg2 ... The arguments specified are sent, verbatim, to the remote
FTP server.
recv remote-file [local-file] (2)
Is a synonym for get.
remotehelp [command-name]
Requests help from the remote ftp server. If a
command-name is specified, it is also supplied to the
server.
rename [from] [to] Renames the file from on the remote machine, to the file
to.
reset Clears reply queue. This command re-synchronizes
command/reply sequencing with the remote ftp server.
Resynchronization may be necessary following a violation of
the FTP protocol by the remote server.
rmdir directory-name
Deletes a directory on the remote machine.
runique Toggles storing of files on the local system with unique
file names. If a file already exists with a name equal to
the target local file name for a get or mget command, a .1
is appended to the name. If the resulting name matches
another existing file, a .2 is appended to the original
name. If this process continues up to .99, an error
message is printed, and the transfer does not take place.
The generated unique file name is reported.
Note: runique does not affect local files generated from a
shell command (see below). The default value is off.
Processed July 12, 1991 FTP(1c,C) 8
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
send local-file [remote-file] (1)
Is a synonym for put.
sendport Toggles the use of port commands. By default, ftp sends a
port command before each data transfer.
status Shows the current status of ftp .
struct [struct-name]
Sets the file transfer structure to struct-name. The only
supported structure is file.
sunique Toggles the storing of files on remote machine under unique
file names. Remote FTP server must support FTP protocol
STOU command for successful completion. The remote server
reports unique name. Default value is off.
tenex Sets the file transfer type to that needed to talk to TENEX
machines.
trace Toggles packet tracing.
type [type-name] Sets the file transfer type to type-name. If no type is
specified, the current type is printed. The default type
is network ASCII; the other types available are image and
EBCDIC.
user user-name [password] [account]
Identifies the user to the remote FTP server. If the
password is not specified and the server requires it, ftp
prompts the user for it (after disabling local echo). If
an account field is not specified and the FTP server
requires it, the user is prompted for it. If an account
field is specified, an account command is relayed to the
remote server after the login sequence is completed if the
remote server did not require it for logging in. Unless
ftp is invoked with auto login disabled, this process is
done automatically on initial connection to the FTP server.
verbose Toggles verbose mode.
? [command] Is a synonym for help.
Command arguments which have embedded spaces may be quoted with quote (" ")
marks.
-------------------
(1) New remote files or directories transferred by send, put, mput, and mkdir
will reflect the default for the remote machine, regardless of the personal
umask value you have set on either the local or remote machine. On AIX/370
Processed July 12, 1991 FTP(1c,C) 9
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
systems, this will be 644 for files (-rw-r--r--) and 755 for directories
(drwxr-xr-x).
(2) New local files transferred by get, mget, recv, dir, mdir, ls, and mls will
reflect the umask value you have set on the local machine, or the system
default, if you haven't set a personal umask value.
ABORTING A FILE TRANSFER
To abort a file transfer, use the terminal Ctrl-C (INTERRUPT) key. Sending
transfers are immediately halted. Receiving transfers are halted by sending a
FTP protocol ABOR command to the remote server, and discarding any further data
received. The speed at which this is accomplished depends upon the remote
server's support for ABOR processing. If the remote server does not support
the ABOR command, an "ftp>" prompt does not appear until the remote server has
completed sending the requested file.
The terminal INTERRUPT key sequence is ignored when ftp has completed any local
processing and is awaiting a reply from the remote server. A long delay in
this mode may result from the ABOR processing described above, or from
unexpected behavior by the remote server, including violations of the FTP
protocol. If the delay results from unexpected remote server behavior, the
local ftp program must be killed by hand.
FILE NAMING CONVENTIONS
Files specified as arguments to ftp commands are processed according to the
following rules.
o If the file name - is specified, the stdin (for reading) or stdout (for
writing) is used.
o Failing the above check, if globbing is enabled local file names are
expanded according to the rules used in the C shell. File name expansion
occurs only with mdelete, mget and input.
o For mget commands and get commands with unspecified local file names, the
local file name is the remote file name, which may be altered by a case,
ntrans, or nmap setting. The resulting file name may then be altered if
runique is on.
o For mput commands and put commands with unspecified remote file names, the
remote file name is the local file name, which may be altered by a ntrans
or nmap setting. The resulting file name may then be altered by the remote
server if sunique is on.
PARAMETERS
The FTP protocol specifies many parameters which may affect a file transfer.
The type may be one of ASCII, binary, EBCDIC, and local byte size. FTP
supports the ASCII and image types of file transfer, plus local byte size 8 for
Processed July 12, 1991 FTP(1c,C) 10
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
TENEX mode transfers.
FTP supports only the default values for the remaining file transfer
parameters: mode, form, and struct.
THE .NETRC FILE
The .netrc file contains login and initialization information used by the auto
login process. It resides in the user's home directory. The following tokens
are recognized. They may be separated by spaces, tabs, or new lines:
machine name Identifies a remote machine name. The auto login process
searches the .netrc file for a machine token that matches the
remote machine specified on the ftp command line or as an open
command argument. Once a match is made, the subsequent .netrc
tokens are processed, stopping when the end of file is reached
or another machine token is encountered.
login name Identifies a user on the remote machine. If this token is
present, the auto login process initiates a login using the
specified name.
password string
Supplies a password. If this token is present, the auto login
process supplies the specified string if the remote server
requires a password as part of the login process.
Note: If this token is present in the .netrc file, ftp stops
the auto login process if the .netrc is readable by anyone
besides the user.
account string Supplies an additional account password. If this token is
present, the auto login process supplies the specified string if
the remote server requires an additional account password, or
the auto login process initiates an ACCT command if it does not.
macdef name Defines a macro. This token functions like the ftp macdef
command functions. A macro is defined with the specified name.
Its contents begin with the next .netrc line and continues until
a null line (consecutive new-line characters) is encountered.
If a macro named init is defined, it is automatically executed
as the last step in the auto login process.
FILE TRANSFER BETWEEN AIX AND VM
If ftp determines that it is communicating with an EBCDIC machine, all
subsequent file transfers are automatically translated into EBCDIC,
transparently to the user. EBCDIC translations are determined by the user's
current locale. For example, if the user's current locale is Japanese, a
Japanese EBCDIC file is transferred to or from the EBCDIC machine. The
conversion table for the translation configuration file is japanese.en,
normally located in the /usr/lib/mbcs directory. For the EBCDIC translation,
Processed July 12, 1991 FTP(1c,C) 11
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
the MBNLIN and MBNLOUT tokens in the environment file for the locale define
the conversion table for input and output, respectively.
Since current EBCDIC does not support multibyte file names, all EBCDIC side
file names should contain only ASCII characters. On the AIX side, however,
the user may choose file names that are legal in the current locale (for
example, Japanese characters in a Japanese locale).
EXAMPLES
o The user "smith" is logged in on "host1". This example shows how "smith"
can log in on the foreign host "host2", check the current working directory
on "host2", list the contents of the working directory, and then transfer
the file "testfile" to "tmp.testfile":
$ ftp host2
connected to host2.
220 host2 FTP Server ready.
Name (host2:smith):
331 Passwd required for smith
Password:
230 User smith logged in
ftp> binary
200 Type set to I
ftp> pwd
550 "/u/smith" is current directory
ftp> ls
200 PORT command successful.
150 Opening data connection for /bin/ls (192.9.200.1,1026) (0 bytes)
pri
testfile
226 Transfer complete.
26 bytes received in 0.12 seconds (0.22 Kbytes/s)
ftp> get testfile tmp.testfile
200 PORT command successful.
150 Opening data connection for testfile (192.9.200.1,1029) (1201 bytes)
226 Transfer complete.
local:tmp.testfile remote:testfile
1201 bytes received in 0 seconds (1.2 Kbytes/s)
ftp> quit
221 Goodbye.
$ _
o The user "smith" is logged in on "host1." This example shows how "smith"
can log in as the user "smith" on the foreign host "host2.":
Processed July 12, 1991 FTP(1c,C) 12
FTP(1c,C) AIX TCP/IP User's Guide FTP(1c,C)
$ ftp host2
connected to host2
220 host2 FTP Server ready.
Name (host2:smith):
331 Passwd required for smith
Password:
230 User smith logged in
ftp>
o The user "fred" makes a typing error and tries to log in as the user
"miths":
$ ftp host2
connected to host2
220 test FTP Server ready.
Name (test:fred): miths
530 User miths access denied
ftp> user smith
331 Passwd required for smith
Password:
230 User smith logged in
ftp>
o The user "fred" issues the ftp command without specifying a host name:
$ ftp
ftp> open host1
connected to host1
220 host1 FTP Server ready.
Name (host1:fred):
331 Passwd required for fred
Password:
230 User fred logged in
ftp>
FILES
.netrc Is the auto login file in the current or home directory.
/etc/shells Is the list of authorized shells.
RELATED INFORMATION
In this book: "ftpd"
Processed July 12, 1991 FTP(1c,C) 13