CogSci
3
Introduction to Computing

Home

Syllabus

Schedule

Contact Us
Regrade Form

Printable
Version

Department of
Cognitive
Science

Using FTP

What is FTP?

For this course, the term FTP will be used to mean 3 different, but related concepts.
  1. First, the general notion of copying files back and forth over a network, but without using a file server.
  2. The File Transport Protocol or FTP, a network protocol for copying files over a network.
  3. And, finally, the actual command line oriented FTP program itself, as found in UNIX or Windows.

Copying Files over the Internet

In this course, we will sometimes use the notion of "FTP" to mean copying files back and forth over the Internet, as opposed to file serving. The actual software application used might be the command line oriented FTP program, or more than likely, one of the graphic front ends to the FTP protocol, like Fetch or WS-FTP. We may say: "you can FTP your files" to mean that you can copy your files over the network using an "FTP like" program.

You could also use one of the secure/SSH based versions like SCP (Secure Copy Program) or SFTP (Secure FTP), or their graphic front ends. These all use encryption for the login process (when you enter your username and password on the server) as well as for the data transfer to keep your information private. You should prefer to use a secure version of FTP if you can; we are going to refer to both secure and unsecure versions as just FTP.

FTP requires an Internet network connection. In order to use FTP from home, you must have an ISP (for DSL or cable modem), or use the PPP (Point to Point Protocol) software with a dial up service provider (like campus Network Operations or AOL, Earthlink, etc).

Using FTP in a browser

You can use an Internet browser like Internet Explorer or Netscape Navigator to download files from an anonymous FTP server on the Internet to your computer using FTP. Just use the ftp:// URL scheme along with the address of the FTPserver as the URL. The browser will take care of logging you in as user "anonymous". For instance, in the figure at the right, we have accessed files on ntserve.ucsd.edu using the URL: ftp://ntserve.ucsd.edu (using the Macintosh version of Internet Explorer ).

However, to upload files (like your homework) from your home computer to the class server, you must have an FTP program. (You will also need to have an account on the computer you wish to upload to.) Not only will FTP let you turn in your homework from home, but you can also upload (or download) large files (like software programs) that are too big to fit on a floppy disk.

It's also worth mentioning that while you can send files back and forth via email, many mail servers have limits on the size of a single message. If the data you are sending is binary in nature (like an image, or word processing document), it has to be encoded as ASCII in order to pass through the mail system. This encoding will make the document even larger than it is in its binary format! Frown FTP does not have this size restriction.

This is not the transparent operation that one has using file server disks, such as Appleshare or a network drive, where the remote computer's disk is mounted on your computer, and appears (and acts) just like a local hard disk. On a Macintosh, the file server's disk icon appears on the desktop, while in Windows, the icon appears in "My Computer" (icon usually found on the upper left hand of the desktop; or in the Start menu of Windows XP). With a file server, you are able to double click on the file server icon to open and browse it's contents. You can open (double click) and modify the original copy of a document on the file server. Or using the SaveAs dialog, you are able to navigate directly to the file server disk and save there.

With FTP on the other hand, you must

  1. First copy (FTP) the file from the remote computer to your local hard disk
  2. Then make your modifications, save them
  3. And finally copy (FTP) the new version back either as a new document with a new name, or on top of (replacing) the original.
Note: if you have a slow/sluggish Internet connection to your file server, then each operation with a document will be painfully slow. FTP-ing the file over from the server, and then back (when you are done working) may actually save you time over working in "File server" mode, even though it seems like more steps.

The Network Protocol

The File Transport Protocol or FTP is an old method of accessing a remote computer's disks over a network. It allows you to copy files between the remote computer's disk and the disk(s) on the local computer. Note: the remote computer and local computer can be the same machine; you could use that fact to copy files to or from a friend's account on icogsci1.

FTP is a client/server protocol. In order to access files on a computer via FTP, that computer must be running an FTP server.

The FTP Program

The original FTP is a command line oriented program. That is, the user types in commands to copy files, create directories, get a directory listing, navigate the file system on the remote computer, etc.

Despite its somewhat crufty command line user interface , there are many implementations of FTP, both the client (user oriented) side and the server side. This is one of the main advantages of FTP over the different types of file servers, there are many versions of FTP for a variety of software and hardware configurations. I.e., it is possible to FTP files to/from a server running one type of software (e.g., a Linux server like icogsci1) to a client like Macintosh.

Various FTP Programs
Macintosh Windows
Fetch a shareware FTP client with a nice (Macintosh) graphical user interface. WS-FTPLE a freeware FTP client for Windows with a graphical user interface
Windows comes with a command line oriented FTP
NCSA Telnet or Better Telnet each allow you to start a client FTP session by checking a box in the Connect dialog. If you enable the server mode, NCSA Telnet and Better Telnet will act as an FTP server as long as Telnet is an active application. That means you can FTP back into your Macintosh! NCSA FTP client software for DOS (runs in a DOS window when in Windows)
Secure (SSH) Versions
NiftyTelnet for the Macintosh has an SCP mode. There is no navigation on the remote system (like any SCP). There is a command line SCP for Windows that is part of the PuTTy SSH distribution. As with any SCP, there is no navigation, you have to know where the files are on the remote system
SSH for the Macintosh has SFTP SSH for Windows has SFTP

Using the FTP Program

Command line oriented versions of FTP usually take the name of the remote system that you want to connect to as an argument. Thus, to connect to host icogsci1 (.ucsd.edu), on a UNIX system, you would type:
	ftp icogsci1.ucsd.edu
at the UNIX prompt.

In Windows, you can use the Run command in the Start menu (Start->Run), or open a MSDOS window (in the Programs Menu--in Windows 2000 and XP it is called: Start->(All)Programs->Accessories->Command Prompt), and then type FTP and the host name you want to connect to (like above).

You can also simply type: ftp. Then use the open command within FTP to specify the remote connection. E.g., open icogsci1.ucsd.edu

On a Macintosh with NCSA Telnet, you use the File->Open dialog to specify the host name, and then click the "Ftp Session" box; this will create an out going FTP connection to the host. Note that both NCSA Telnet and Better Telnet allow you to do a somewhat peculiar thing, namely to FTP into your Macintosh. In this scenario, you use Telnet to log into the host (e.g., icogsci1), and then FTP back to your Macintosh. (You may have to set the preferences for the Telnet software to allow for incoming connections). Now the "remote" computer is your Macintosh, and the "local" computer is the host you telnet-ed to.

Local vs Remote

There are a couple of things that make using the command line version of FTP difficult. One is that it is a command line program; you type commands to navigate through the folders and transfer files.

Another thing that makes FTP hard is that there are two computers involved. When you use a file server, there are also 2 computers involved, but you are not really aware of the file server as a computer, since it appears to be a local disk. With FTP, on the other hand, you need to be aware of the both computers: the local one, which has the screen and keyboard you are using. And the remote computer, which is the one you want to upload to, or download from--the one you "FTP to".

Logging In

In order to use FTP, you need to have a computer account on the remote system. Immediately after the connection to the remote computer is completed, you will be prompted for your account name on the remote computer and then a password.

Anonymous FTP Servers

Some special servers, called anonymous FTP servers, let people access a set of public files. With an anonymous server, you open a connection in the normal way, but then log in with the username of anonymous (or sometimes guest or ftp). Instead of your password, give your email address.

For transferring files to or from your class accounts, you will, of course, log in with the appropriate class account and corresponding password.

Some FTP servers, for instance the one built into NCSA Telnet for the Macintosh, do not automatically prompt for the user (account) name after the connection is made. You will have to use the user command within FTP to start the process.

If you make a mistake logging in, say, by mistyping your password, you can restart the log in process by using the user command.

The FTP Commands

You can get a list of the many possible FTP commands by typing a "?" or "help" at the ftp> prompt.
ftp> ?
Commands may be abbreviated.  Commands are:

!               cr              macdef          proxy           send
$               delete          mdelete         sendport	status
account         debug           mdir            put		struct
append          dir             mget            pwd		sunique
ascii           disconnect      mkdir           quit		tenex
bell            form            mls             quote		trace
binary          get             mode            recv            type
bye             glob            mput            remotehelp      user
case            hash            nmap            rename		verbose
cd              help            ntrans          reset           ?
cdup            lcd             open            rmdir
close           ls              prompt          runique
ftp>

Typically, you only use a very small subset of these, for instance, for navigation.

Navigating the Remote File System

Once you have connected and logged in to the remote computer, you will probably need to "move" around both the remote computer's file system to locate the files or directories (same idea as folders you want to work with. FTP uses UNIX-like commands for navigation:


Navigating the Remote File System
cd change current/working directory on the remote system
lcd change current/working directory on the local system
pwd print working directory
mkdir create a new directory/folder on the remote system
rmdir remove a folder/directory
rename change the name of a file or a folder/directory
delete remove a file from the remote system
ls
or
dir
"list" the file names found in the current directory
ls -F show directories, programs, with special notation
ls -l "long" list, with permissions, sizes and dates
ls -a show UNIX "hidden" files, ones that start with a '.'
ls -al long list of hidden files
ls -lt sort a long list by time, most recent first
ls -lrt sort a long list by time, most recent
Notes:
  • Unlike the UNIX version of ls, the FTP ls will accept only a single argument, either a flag (probably the most interesting type of argument), or a file or directory name.
  • Not all FTP servers accept a flag argument to ls

lcd

cd foo is the command to change into directory foo (which is in your current directory) on the remote system. You may also need to change folders on the local system/drive as well. The lcd command (local cd) is used for that.

Navigating through your folders on your PC with lcd can be difficult:

  • Changing directory to a different drive letter can be tricky, depending on exactly which version of FTP you are using on the PC. It might be: lcd a: for instance, or it might be as simple as a: like you would type at a DOS prompt. Or, maybe you have to select both the drive and a folder, like lcd a:\ or lcd c:\temp
  • File and folder names with spaces in them are a major pain. Frown. Use quotes (") around the name with the space in it. E.g., lcd c:\"My Documents"
  • Some FTPs will use 8 characters for the file name, and truncate the rest! (This is a throw-back to the 8.3 file names used in DOS.) Thus, instead of lcd "Program Files", you probably have to do: lcd program~1. Frown

It might be easier to use the "Command Prompt" window to navigate to the folder where you will get your data to or put your data from. And then start FTP afterwards. That way, you shouldn't need to lcd.

By the way, if you start FTP via Start->Run in one of the ACS Windows XP labs, it appears as if the initial local directory is your My Documents folder.

Copying Files -- get

You send a file from the local computer to the current directory on the remote computer. You recv a file from the remote computer.

There are put and get synonyms for send and recv, respectively.

For example:

	get foo
will copy a file called foo from the current directory on the remote computer. The copy will be called foo on the local computer.

You can also rename the file during the copy process.

	get foo bar
will copy foo from the remote computer and call the copy bar on the local computer.

put

If you want to go the other way, from the local computer to the remote computer, use put instead of get. To put a file called index.html into a directory called public_html, you would use the following ftp commands:
	cd public_html
	put index.html

Multiple Files

The file copy commands (e.g., get and put) handle a single file at a time. There are special versions: mget and mput, that copy multiple files at a time. Depending on what type of remote server software is running, you may be able to specify multiple files using wild card notation.

For instance,

	mget *.html
will copy all the files that end in .html.

By default, mget and mput will ask you about each file name before doing the actual copy/transfer. You may find it convenient to use the prompt command before starting the mput or mget to turn off prompting during the copy process. The prompt command is a toggle; use the command once to turn off prompting, use it again to turn prompting back on; like flipping a light switch.

Directory/Folder Hierarchies

FTP does not do a good job of transferring whole hierarchies. Yes, mget and mput will let you copy every file in a directory (and create names for subdirectories), but you must copy the contents of each subdirectory separately by hand.

For large directory structures, it may make sense to "bundle up" the folders and files before FTP-ing, perhaps using the zip program. Then FTP the single bundle and then undo (unzip) it after the copy. UNIX users often use the tar command to create such a bundle, and then use tar again at the remote end to undbundle.

The secure version of FTP called: SCP, usually takes a -r recursive flag argument. The -r copies a directory hierarchy!

Binary or ASCII

Text files should be copied in ASCII mode. ASCII is a 7 bit code describing the English alphabet, digits, punchation, and 32 control characters (like line feed, back space, etc). That is, only 7 of the 8 bits in a byte are used. This is the default transfer mode for FTP.

Some forms of FTP client software (for instance, on the Macintosh and under DOS or Windows) do special processing of the end of line character in text files.

That is, the end of line character for text is a line feed (0xa in hexadecimal) on UNIX systems, but a carriage return (0xd in hex) on the Macintosh. Windows or DOS programs want both a carriage return and line feed at the end of each line. In ASCII mode, FTP will translate the end of line convention on the sending system to that required on the receiving end.

All other files should be transfered in binary mode. If you don't know what sort of file you have, use binary mode. All 8 bits are transfered in binary more. There is no translation of any sort. There is an FTP "binary" command to change to binary mode (just bin will do).

In particular, all graphic images, program files, tar archives, zip files, and even word processing documents (.doc) should be transfered in binary mode. Copying such a file/document in ASCII mode will corrupt it (badly), so that it can't be used.

An Example

Suppose you are using Windows on your machine at home, and have a file called MONKEY.GIF that you wish to FTP to your class account.

  • The first thing to do is locate what folder MONKEY.GIF actually resides in. You can use Start->Find->"Files or Folders". Remember that if you need to, you can stretch the "In Folder" part of the "Find" dialog in order to see the full pathname for the file.
  • Once you have the whole pathname, start up a command line window by Start->Programs->Accessories->Command Prompt (or Start->Programs->Dos Prompt).
  • Use the cd command to change to the folder you found MONKEY.GIF in. Say that folder was: C:\Programs\Netscape\Downloads. You would type:
    	cd c:\programs\netscape\downloads
    
    Note, should part of the folder name contain a space, use quotes (") around the whole folder name. For example, your "My Documents" folder has a space:
    	cd "My Documents"
    
  • Create a network connection for your computer using the procedure you normally use to get on the Internet, perhaps by using "Dialup Networking".
  • Now start up FTP to the class server:
    	c:\programs\netscape\downloads ftp icogsci1.ucsd.edu
    
  • You will be prompted for your user name and password, type in your class account name (cg3xzz) and password.
  • Now you should have an "ftp> " prompt.
  • Make sure that FTP will be doing binary transfers unless you are sure that you want an Ascii transfer.
    	ftp> binary
    
  • You can use the dir command to give you an ls -l type listing of your home directory. And you can use the cd to navigate to subfolders, if you need to. Suppose the MONKEY.GIF file needs ultimately to be in your public_html folder on the class server.
    	ftp> cd public_html
    
  • Now put your file on the server. This may take a few moments depending on the size of your file and the speed of your Internet connection.
    	ftp> put MONKEY.GIF
    
    Or copy, and rename it at the same time by providing a new file name to as the second argument to the put command.
    	ftp> put MONKEY.GIF monkey.gif
    
  • You can use dir to verify the file got there, then quit.
    	ftp> dir
    	ftp> quit
    

A GUI Front End

Much of the command line nature of the original FTP can be masked by a graphical front end. Fetch for the Macintosh and WS-FTP for Windows are such GUIs. Both Fetch and WS-FTP have an initial log in dialog that asks for the remote computer/host name, your login name and password and the directory to start in on the remote host. You can save the information you type in as a "profile" or "short cut".

Once you have logged into the remote computer, you are presented with a somewhat graphical view of the files in the current directory (on the remote computer); something like view that Windows Explorer (not Internet Explorer).

Copying a file can be as easy as double clicking on it.

Fetch

Fetch runs on Macintoshes. Fetch has one of the cooliest "busy" icons: a little running dog!

Here is the Fetch open (log in) dialog.

And here is the display of the remote file system.

Fetch and Macintosh Special Note

The Macintosh file system structure is very different from most other (UNIX, Windows, DOS) file systems. That means a couple of things:
  • In order to copy a Macintosh file from one Mac to another using FTP, you have to use a special format called Macbinary ||.
  • To copy/FTP a file from a Macintosh to a UNIX or Windows system, you probably want to avoid doing a "Macintosh" copy.

Fetch tries to figure out the format to put files in. Sometimes this automatic determination is incorrect, so you should plan to override it manually. Part of the put dialog allows the user to specify the exact format. For images and sounds, "raw binary" is the right choice, probably for Word (or other word processing documents) too.

WS-FTP

WS-FTP runs under most versions of Windows. The current free version is called WSFTPLE (LE = Light Edition, I presume).

Here is the initial, "log on" window.

And here is the display once you have logged into the remote system.

The WS-FTP dialog is similar to Fetch's except there are 2 sets of files listed. The files and folders on the left are on the local disk; those on the right are on the remote system.

Generally, the names of all the folders are displayed before the file names, however, you can alter that behavior (select the Options button). As in UNIX, .. is a shortcut for the parent/upper folder. Click on the .. entry to move up one folder level, just like in the Windows Save and Open dialogs.

As usual with Windows, you need to be careful about the 8.3 type filenames.

To copy a file, from the system and folder on the left (the local system) to the folder on the right, simply select the file (or folder) in the left window and then click the -> button. WS_FTP will copy a whole folder hierarchy too--much more convenient than the command line FTP.

Getting WS_FTP

If you have a Windows computer at home, and would like to use WS_FTP, you first need to get a copy of the application. If you bought the dialin connection software from Network Operations, then you probably already have the software. Otherwise, you maybe able to get a copy via Google (or elsewhere on the Internet).

You can download the ws_ftple.exe installer file from the Windows_NT->ftp folder (on ntserve). Be sure to remember the folder that you specified in the SaveAs dialog.

Once it has copied down, then you can open that folder, and double click on ws_ftple to get it installed.

Or use the command line oriented FTP. First, Start->Programs->MSdos to open a dos window. Then in that window type:

  • 	mkdir c:\temp
    	cd c:\temp
    
  • ftp ntserve.ucsd.edu
  • Login as: anonymous
  • For your password, give your @ucsd email address
  • At the ftp> prompt, type:
    	cd windows_nt/ftp
    	binary
    	get ws_ftple.exe
    
  • There will be a pause as the program is copied, then a message about how many bytes were copied.
  • Quit from FTP
    	quit
    
  • Now install the program by typing:
    	ws_ftple
    
    and answering the questions

FTP Summary

  • When we say "FTP your file", we mean copy it over the network using an FTP type program.
  • FTP stands for File Transfer Protocol
  • FTP is not as convenient to use as a file server. You have to copy the file(s) to the local machine before you can work on them, and then copy them back. But you can accomplish the same tasks.
  • FTP is not convenient for copying a folder or directory hierarchy. (You can copy multiple files at a time, but not the contents of folders).
  • The most frequently used commands are:
    • get (from remote computer to local one)
    • put (from the local hard disk onto the remote computer)
    • binary (set the transfer mode to binary for images, word processing documents--everything but text files)
  • Use cd to change folders on the remote system
  • Use lcd to change folders on the local system
  • Use quotes (") around files or folder names with spaces in them; e.g., lcd c:\"my documents"
  • You can copy files to or from your friends account (with their permission, of course ).
    • Log in to your account
    • ftp to your friend's computer (it can be the same as yours!)
    • have your friend log in as herself (at the ftp username:> prompt)
    • get or put files! The "local" files are your account, the "remote" files are your friend's.
  • Fetch and WS-FTP are graphical versions of FTP
  • you might need to be careful of 8.3 filename limitations if you are using Windows and/or WS-FTP
  • If you are using a Macintosh, then use Macbinary mode to transfer objects which should wind up as Macintosh objects (documents, applications). Be sure not to use Macbinary to transfer things that will wind up not being Macintosh objects; e.g., graphic images.
  • You can use FTP to copy files that are larger than a floppy.
  • You can use the ftp:// as the scheme in a URL to download files from within a browser.

Terms to Know

8.3 download lcd remote
anonymous FTP servers encryption local scheme
binary Fetch mget send
byte folders mounted toggle
client/server FTP mput upload
current directory get put WS-FTP
directories get recv

WML
©opyright 1995-2004 Mark R. Wallen
Last updated: Sun Sep 19 12:20:41 2004