Header left.png

FTP Services

From Systems Group
Jump to: navigation, search

FTP (File Transfer Protocol) is the mechanism for transferring files over the Internet. Although most browsers provide some support for FTP, they usually only permit downloads (from the remote machine to your local PC) and usually only permit access to public repositories, not to password-protected accounts.

You can only use FTP to transfer files to or from a machine that has been set up as an FTP server. In the ODU CS Dept., we have one such machine: ftp.cs.odu.edu.

Anonymous versus Private FTP

When you connect to an FTP server, you will be prompted for a login name and password. Thus, in the .normal. mode of FTP, you must have an account on the server system.

But some servers also have been set up to provide files to the public at large. By convention, servers that allow this do so by recognizing a special login name, .anonymous. , for which almost any password is accepted. Again, by convention, users who log in as .anonymous. are expected to supply their own email address as the password.33 On the CS Dept server, ftp.cs.odu.edu, you can log in as .anonymous. to gain access to the public area. You cannot, however, access your own files from there. Alternatively, you can log in with your own Unix account login name and password, in which case you will have access to your own files and directories on the Unix network, but cannot access the public area.

This helps explain why you need to learn to use FTP rather than relying on your web browser for file transfer. Web browsers, when directed to an ftp://. URL, do an anonymous login. If you need access to your own files and directories, that's no help.

Transferring Files

To transfer files via FTP, you need to have an FTP client program on the machine at which you are sitting. In a sense, this is very similar to telnet, where you run a .telnet client. program on your local machine and use it to issue commands to a remote one. The ftp client program also runs on your local machine and allows you to issue commands to a remote one, but these commands are all related to file transfers.

Not surprisingly, the way you actually launch and run the client depends upon just which client you have. MS Windows comes with an FTP client, called ftp.34 CygWin provides another client, with the same name, which works almost identically. These offer a text-based interface. However, there are a variety of FTP clients, commercial and freeware, that offer window-GUI interfaces. You'll find some of these listed on the course Library page.

PCs on the labs maintained by OCCS have actually removed the default Windows ftp client program from many machines, and have installed the Hummingbird ftp client, which offers a familiar drag-and-drop style interface. Access this program in the .Start->Programs. listing as .Hummingbird Connectivity.->Host Explorer->FTP. .

GUI interfaces can simplify FTP use, but these interfaces often create problems by hiding the text/binary settings, leading to corrupt transfers.

FTP via a Text Interface:

To use the MS Windows ftp, click the .Start. button, select .Run. , and for the program name type

ftp ftp.cs.odu.edu

(Assuming you want to connect to the CS Dept. server. If you have reason to access another FTP server, just replace the machine name accordingly.)

If you are running the CygWin ftp, just type the same command into your shell. You will then be prompted for your login name and your password. Enter those as usual. Your next command should be hash

This simply increases the amount of feedback you get about the progress made during file transfers. Before actually transferring files, you must decide whether to use binary or text file transfer. If you want binary transfers, give the command binary

and if you want text transfers, give the command ascii

You can switch back and forth between these modes as necessary if you are transferring multiple files, some text and some binary. Now you can use the commands cd, pwd, and ls to navigate the Unix directory structure as if you were in the shell. usually, you will cd to the directory of the remote machine in which you wish to download or upload files, do an ls to see what's there, and then proceed to transfer the specific files.

You can also change the directory of the local machine in which you will be working by giving the lcd (local cd) command. Note that the directory you give to this command must make sense in terms of the local machine's directory structure. For example,

lcd c:\courses\cs252

for the MS Windows ftp client, but get filename To put a file form your local machine onto the CS Unix machine, the command is put filename Neither the get nor put commands can include wildcards (* ?) in the filename, but by changing the commands to mget and mput, you are allowed to use wild cards.

To end your ftp session, the command is quit

Here, then, is an example of an ftp session in which three files were downloaded from ~jdoe/data on the Unix network into c:\misc\temp on the local PC:

Connected to ftp.cs.odu.edu
220 ProFTPD 1.2.Opre10 Server (ODU CS FTP Server)
User (ftp.cs.odu.edu(none))): jdoe
331 Password required for jdoe.
Password:
230 User jdoe logged in
ftp> hash
Hash mark printing On ftp: (2048 bytes/hash mark) .
ftp> lcd c:\misc\temp
Local directory now C:\misc\temp
ftp> cd data
250 CWD command successful
ftp> ls
200 Port Command successful
Directory of /home/jdoe/data
file1.txt
file2.dat
file3.txt
file4.dat
226 Transfer Complete
ftp> ascii
200 Type set to A.
ftp> get file1.txt
200 PORT command successful
150 Opening ASCII mode data connection for file1.txt (20101 bytes). #########
226 Transfer complete
ftp: 20627 bytes received in 1.17 seconds
ftp> binary
200 Type set to I.
ftp: mget *.dat
200 Type set to I.
mget: file2.dat? y
200 PORT command successful
150 Opening BINARY mode data connection for file2.dat (1001 bytes).
226 Transfer complete
ftp: 1001 bytes received in .23 seconds
mget: file4.dat? y
200 PORT command successful
150 Opening BINARY mode data connection for file4.dat (2123 bytes). #
226 Transfer complete
ftp: 2123 bytes received in .35 seconds
ftp> quit

(You may notice that, during the ASCII mode transfer, the number of bytes transferred was larger than the size of the file. That's because, in an ASCII transfer from a Unix machine to a Windows machine, each new-line character is replaced by a carriage-return character followed by a new-line.)