UB Information Technology

Documentation

ftp

Documentation print footer; appears at "bottom" of first page.

Adobe Reader 7 for Windows

Platform: Windows

ftp

Platform: UNIX

Introduction

ftp is a user interface to the ARPANET standard File Transfer Protocol (FTP). ftp transfers files to and from a remote network host and the local host. ftp is available on UBUnix.

Setup

To use ftp, ensure you are using the default system path or that it is included in your path.

Starting ftp

You can specify the remote host with which ftp is to communicate on the command line by entering:
ftp hostname

When instructed, enter your UBIT Name and Password and press Return. ftp will immediately attempt to establish a connection to an ftp server on that host or it will enter its command interpreter without opening a connection. When ftp is awaiting commands from the user, it displays the prompt ftp>.

Options

ftp has several options listed below. Options can be specified on the command line when ftp is invoked.

Option Description
-d Enables debugging
-i Turns off interactive prompting during multiple file transfers
-n Does not attempt auto-login upon initial connection. If auto-login is enabled, ftp checks the file .netrc in the user's home directory for an entry describing an account on the remote host. If no entry exists, ftp prompts for the login name of the account on the remote host (the default login is the login name on the local host), and, if necessary, prompts for a password
-v Shows all responses from the remote server and reports on data transfer statistics. This is turned on by default if ftp is running interactively with its input coming from standard input

File Naming Conventions

Local files specified as arguments to ftp commands are processed according to the following rules:

For get and mget commands with unspecified local filenames, the local filename matches the remote filename.

For put and mput commands with unspecified remote filenames, the remote filename matches the local filename.

If the remote directory is not specified, ftp uses the current working directory on the remote host.

A wildcard character, *, in a filename expands to zero or more characters.

ftp Command Interpreter

In addition to command line switches, it is possible to give commands within ftp. After establishing a connection using ftp, you can select from the following partial list of ftp commands.

Parameters specified with [ ] are optional parameters.

Command Description
!command Runs command as a shell command on the local host. If no command is given, invokes an interactive shell
append local-file [remote-file] Appends a local file to a file on the remote host
ascii Sets the transfer mode to ASCII (default)
bell Sounds a bell after each complete file transfer
binary Sets the transfer mode to image
bye Closes the ftp session with the remote server and exits ftp
cd remote-dir Changes the working directory on the remote host to remote-dir
close Closes the ftp session with the remote server, and returns to the ftp command interpreter
delete remote-file Deletes remote-file on the remote host
dir [remote-dir] [local-file] Lists directory contents of the remote directory remote-dir, and optionally places the output in local-file
get remote-file [local-file] Retrieves the remote-file, and stores it on the local host
help [cmd] Displays a summary of cmd
lcd [dir] Changes the working directory on the local host. If no directory is specified, the user's home directory is used
ls [remote-dir] [local-dir] Displays an abbreviated listing of the contents of a directory from the remote host
mget remote-files Expands wildcards for remote-files on the remote host, issues the get command for each filename produced. Files are stored in the local working directory
mput local-files Expands wildcards in the list of local files given, and executes put for each file
open host [port] Establishes a connection to the specified host ftp server. An optional port number can 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 into the ftp server
prompt Toggles interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. By default, prompting is turned on. If prompting is turned off, any mget or mput transfers all files, and any mdelete deletes all files
put local-file [remote-file] Stores a local file on the remote host
pwd Displays the name of the current working directory on the remote host
status Shows the current status of ftp and options
user Specifies login name to remote system

Aborting a File Transfer

To abort a file transfer, use the terminal interrupt key (usually Ctrl c). Sending transfers are immediately halted. Receiving transfers are halted when the abort is sent to the remote server. The speed at which this is accomplished depends on the remote server's support for abort processing. If the remote ftp server does not support the abort command, the ftp> prompt does not appear until the remote server has completed sending the requested file.

Example

The following example is brief. However, the best way to learn about using ftp is by experimenting with it. It is safest to use a new, empty directory, so that you do not accidentally copy over important files.

To start ftp and open a connection to a host you might enter:
ftp somehost.edu

somehost.edu is the name of the remote host with which you want to connect. ftp responds with something similar to the following:
Connected to somehost.edu
220 somehost.edu FTP server (SunOS 4.1) ready.
Name (somehost.edu:username):
331 Password required for username.
Password:
230 User username logged in.
ftp>

username is your username on the local host. If your username is correct, press Return, or enter the correct username, then press Return. Enter your password when prompted. You will receive the ftp> prompt, at which point you can enter ftp commands, such as get and put. To receive a file named from.there from the remote host and save it in a local file called to.here, you have the following sequence:
ftp> get from.there to.here
200 PORT command successful.
150 ASCII data connection for from.there
    (128.205.2.3,1296) (96028 bytes).
226 ASCII Transfer complete.
local: to.here remote: from.there
10124 bytes received in 1 seconds
    (10 Kbytes/second)
ftp>

Exiting ftp

To exit ftp, enter bye at the command prompt and press Return.

Additional Information

To read the online manual page, enter the following at the UBUnix prompt:
man ftp

You can also enter help at the ftp prompt. Additional information related to file transfer can be found in the manual pages for csh, tcsh, rcp, and netrc.

Related Documents

Document Information

Title: ftp
Document Category: UNIX
Document Number: UNX-009