UP ONE LEVEL:
ENEL 315 Home Page
Introduction to ftp
ENEL 315 Lab Tip, Winter 1998
This is NOT a course handout - to save paper,
no paper copies have been printed.
Author: Steve Norman
Last modified: Mon Feb 9 01:29:46 MST 1998
Contents
Introduction
The main purpose of the
ftp program is to allow copying of
files from one computer system to another over a network.
There are two main ways of using ftp:
-
A session where you have accounts on the systems at both ends of
the ftp connection.
-
An `anonymous ftp' session, where you are downloading
files made available to the public on some remote system.
This Web page will concentrate on sessions of the first type.
ftp can also be used to copy files from one account
to another on a single computer.
On Unix systems, this helps students working on
a group projects, by allowing them to exchange files
without having to change permissions on files.
ftp is available on Windows NT - just start up
a Command Prompt window, and type in commands as if
you were using Unix.
[back to top of document]
Making a Connection
To connect to a remote computer, start by typing the command
ftp remote-computer
to the Unix shell prompt.
For example, if you are logged in to an ENGG machine and want to
make an ftp connection to the ENEL machine red04,
the command would be
ftp red04.enel
You will then be asked by ftp for your username and password
on the remote computer.
[back to top of document]
Basic Commands
Here is a little bit of terminology:
- The local host is the computer on which you started
the ftp session.
- The remote host is the computer to which you have
made an ftp connection.
This is far from a complete list.
See a good Unix reference book for information about advanced features.
-
quit
Terminate the ftp session.
-
bye
Same as quit.
-
cd remote-directory
Change working directory on the remote host.
-
lcd local-directory
Change working directory on the local host.
-
!command
Execute a command on the local host.
For example,
!ls
would list files in the working directory on the local host.
Warning: Don't use
!cd local-directory
to change directories on the local host. It won't work.
Use lcd instead.
-
pwd
Print name of working directory on remote host.
-
dir
List contents of working directory on remote host.
-
get remote-file local-file
Copy remote-file from
the working directory on the remote host
to the working directory on the local host,
naming the file local-file on the local host.
-
get remote-file
Copy remote-file from
the working directory on the remote host
to the working directory on the local host,
without changing the file name.
-
put local-file remote-file
Copy local-file from
the working directory on the local host
to the working directory on the remote host,
naming the file remote-file on the remote host.
-
put local-file
Copy local-file from
the working directory on the local host
to the working directory on the remote host,
without changing the file name.
-
ascii
Set the file transfer type to ASCII, which is
appropriate for copying text files.
-
binary
Set the file transfer type to binary, which is
appropriate for copying non-text files.
If you're transferring non-text files, it's important
to remember to use this command first - otherwise,
the files may be garbled beyond repair.
Two other useful commands are mget and mput,
which allow transfer of many files with a single command.
See a Unix book or the ftp manual page for details.
[back to top of document]
A Simple Example Session
Suppose you are a user with a real-life name of
John Q. Ampere, with an ENGG account under
the name jqampere, and an ENEL account
under the name amperej.
Suppose further that you want to copy the file
~/enel315/lab22/foo.cpp
from the ENEL system to the directory ~/enel315/lab22
in the ENGG system.
(Remember that ~ is shorthand for your own
home directory on a Unix system.)
There are many different ways to do this with ftp.
Here is one way:
-
Log in to an ENGG computer as jqampere
-
Before establishing an ftp connection, use
cd enel315/lab22
to get into the right directory on the ENGG computer.
- Start an ftp session with the command
ftp red07.enel.ucalgary.ca
- When prompted for a username and password,
enter amperej (your ENEL username) and
your ENEL password.
-
Use the command
cd enel315/lab22
to get into the correct directory on the ENEL machine.
-
Use the command
dir
to make sure that the file you want to copy is where you thought
it was.
-
Use the command
get foo.cpp
to copy the file.
-
Use the command
quit
to end the ftp session.
[back to top of document]
For More Information
For more information,
use the Unix command man ftp to read the online
manual page,
or consult one of the Unix reference books available in
the computer labs.
[back to top of document]