$title = "ftp - file transfer"; $area = "Unix Support"; $metadata = "unix, file, transfer, ftp"; $pfloc = ""; require '/usr/local/wwwdocs/ucs/fragments/header.phtml'; require '/usr/local/wwwdocs/ucs/fragments/header-bc.phtml'; ?>
The ftp command transfers files to or from a remote computer using the standard File Transfer Protocol.
ftp host
where host is the name of the remote computer. You are prompted to log in to the remote computer; once this has been done, ftp commands can be issued in response to the ftp> prompt.
finan [sparc] 14% ftp fred.ic.ac.uk Connected to fred.ic.ac.uk. 220 fred FTP server (SunOS 5.7) ready. Name (fred:abc1): xyz2 331 Password required for xyz2. Password: 230 User xyz2 logged in. ftp>
In the above example, a user with the login name abc1 on finan is connecting to the the computer called fred.ic.ac.uk where their login name is xyz2.
When using ftp, the contents of the file being transferred will overwrite those of any file which already exists at the destination, and which has the same name. Also, if the file being transferred is empty, it will delete the contents of any existing file with the same name.
As its default, the Sun ftp command uses text (ASCII) transfer. If you think that the file you wish to transfer is binary (perhaps it is a program, or a word-processed file, or a picture) type the command binary before transferring the file. If you don't use binary when it is needed, the file will be useless at the site to which it has been transferred.
Most of these commands will be found to work in most ftp systems, but consult the man page for the command on the system you are using before trying them. Square brackets denote optional items.
help [command]
With no parameter, list all commands available; with command, give help on the command specified.
cd remote-directory
Change directory on the remote host.
close
Close the connection to the remote computer without quitting ftp.
dir [remote-directory]
Provide a directory listing of the remote host.
ascii
Set transfer type to ASCII (required for transferring text files - this is the default setting).
binary
Set transfer type to binary (for transferring nontext files, such as program files, word processor documents, etc.).
bye
Terminate the ftp session.
get remote-file [local-file]
Transfer a file to the local computer from the remote host. If local-file is not given, the local copy has the same name as the remote file.
lcd local-directory
Change directory on the local host.
ldir [local-directory]
Provide a directory listing on the local host.
mget remotefiles
Transfer multiple files from the remote host to the local computer. Wildcards in remotefiles will be expanded.
mput localfiles
Transfer multiple files to the remote host from the local computer. Wildcards in localfiles will be expanded.
open remote-host
Open connection to remote computer from within ftp.
prompt
Toggles prompting of individual files which occurs when multiple files are being transferred. The default is on.
put local-file [remote-file]
Transfer a file to the remote host from the local computer.
ftp ftp.mirror.ac.uk Connected to ftp.mirror.ac.uk. 220 UK Mirror Service FTP server version 1.4 ready Name (ftp.mirror.ac.uk:nabc1): anonymous 331 Guest login ok: please send your email address as the password Password: 230- Welcome to the UK Mirror Service funded by JISC 230- More information can be found at our web site: http://www.mirror.ac.uk/ 230- Please send comments or questions to help@mirror.ac.uk 230 Logged in for anonymous FTP ftp> dir 200 Data port set 150 About to open data connection drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 collections drwxrwxr-x 1 ukms ukms 512 Apr 17 08:11 indexes drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 sites drwxr-xr-x 1 ukms ukms 1024 Sep 16 1999 ukms 226 Transfer complete 259 bytes received in 0.018 seconds (13.99 Kbytes/s) ftp> cd sites 250 Current directory now /sites ftp> dir 200 Data port set 150 About to open data connection drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 archives.math.utk.edu drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 beowulf.gsfc.nasa.gov drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 ccrma-ftp.stanford.edu drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 cnbc.cmu.edu drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 datura.ece.uiuc.edu ... 226 Transfer complete 11592 bytes received in 0.68 seconds (16.72 Kbytes/s) ftp> cd ftp.xemacs.org 250 Current directory now /sites/ftp.xemacs.org ftp> dir 200 Data port set 150 About to open data connection drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 pub 226 Transfer complete 61 bytes received in 0.024 seconds (2.51 Kbytes/s) ftp> cd pub 250 Current directory now /sites/ftp.xemacs.org/pub ftp> dir 200 Data port set 150 About to open data connection drwxr-xr-x 1 ukms ukms 1024 Apr 17 01:00 xemacs 226 Transfer complete 64 bytes received in 0.015 seconds (4.08 Kbytes/s) ftp> cd xemacs 250 Current directory now /sites/ftp.xemacs.org/pub/xemacs ftp> dir 200 Data port set 150 About to open data connection ... drwxr-xr-x 1 ukms ukms 1024 Jul 7 1999 xemacs-20.4 drwxr-xr-x 1 ukms ukms 512 Jul 7 1999 xemacs-21.0 drwxr-xr-x 1 ukms ukms 1536 Feb 14 03:13 xemacs-21.1 226 Transfer complete 1466 bytes received in 0.068 seconds (21.14 Kbytes/s) ftp> cd xemacs-21.1 250 Current directory now /sites/ftp.xemacs.org/pub/xemacs/xemacs-21.1 ftp> dir 200 Data port set 150 About to open data connection ... -r--r--r-- 1 ukms ukms 781211 Feb 13 16:02 xemacs-21.1.9-elc.tar.gz -r--r--r-- 1 ukms ukms 1504586 Feb 13 16:03 xemacs-21.1.9-info.tar.gz -rw-r--r-- 1 ukms ukms 6511324 Feb 13 16:08 xemacs-21.1.9.tar.gz 226 Transfer complete 2547 bytes received in 0.027 seconds (91.71 Kbytes/s) ftp> binary 200 Type set to I ftp> get xemacs-21.1.9.tar.gz 200 Data port set 150 About to open data connection 226 Transfer complete local: xemacs-21.1.9.tar.gz remote: xemacs-21.1.9.tar.gz 6511324 bytes received in 88 seconds (72.64 Kbytes/s) ftp> bye 221 Goodbye finan [sparc] 18%require '/usr/local/wwwdocs/ucs/fragments/footer.phtml'; ?>