TRANSFERRING FILES TO AND FROM BARNEY (FTP)

Transferring files to and from Barney is done using the File Transfer Protocol, more commonly referred to as FTP. Using FTP, you can transfer files to and from Barney regardless of whether you are using a PC, a Mac, a UNIX server halfway around the world, or any other type of computer that supports FTP. In order to FTP into Barney, you must have an account; Barney does not allow "anonymous" FTP.

HOW FTP WORKS

FTP works by having an FTP client log into an FTP server. Barney is configured as both an FTP client and server so you can both log into and out of Barney using FTP. Personal computers usually are configured to be only an FTP client. FTP clients can only log into FTP servers, no one can log into an FTP client. This is done to keep others from logging into a computer without authorization and transferring files to or from that computer. FTP servers must be configured with accounts and passwords to ensure sufficient security.

When logging into an FTP server, an FTP client must enter an account and password. Many FTP servers are configured with an account called "anonymous." This account allows a user to login and download files from the server even though they don't have an account on the FTP server. This is commonly used on servers that archive software such as shareware and public domain software and are commonly known as "Anonymous FTP Sites." Barney is not configured to allow anonymous logins.

Once an FTP client has logged into an FTP server, the user is able to view file directories, download and upload files to the server, and even delete files if they have proper authorization.

LOGGING INTO AN FTP SERVER

How you log into an FTP server will depend on whether you are using a command line interface such as UNIX or a graphical interface such as Mac or Windows. From UNIX (e.g., Barney) or other command line interface, you would type ftp server.name (e.g., ftp barney.gonzaga.edu) to log into the specified server. If a successful connection occurs, you will be prompted for your username and password. If you are connecting with an anonymous FTP site, type anonymous for the username and your e-mail address as the password. If you have entered a valid username and password, you will then have a prompt from which to enter commands.

Graphical user interface (GUI) operating systems such as Mac and Windows normally don't require you to enter commands directly. Regardless of the FTP client software you use on a GUI computer, you must first open a connection and then enter a username and password. Once you have logged in, you will typically be able to browse files and directories just as you would on your local hard drive. Many of the following instructions have little relevance to GUI users since they typically don't need to enter commands directly. Some FTP client software for GUI computers (e.g., WinQVT) does require the entering of commands.

LISTING FILES AND DIRECTORIES

When you are connected to an FTP server, you can view a listing of files on that server by entering the command ls or dir. This will list all of the files and directories in the current directory. If you FTP into Barney, the current directory starts as your home directory. Here is a typically listing from ls:

-rw-r--r-- 1 francis cis 21103 Aug 6 13:28 ANSYS52

drwx------ 2 francis cis 1024 Aug 12 08:40 Mail

drwxrwxrwx 2 francis cis 1024 May 31 08:17 bin

-rw-rw-rw- 1 francis cis 27 May 29 15:11 forward

drwxrwxrwx 2 francis cis 1024 Aug 2 17:56 manpgasc

drwxrwxrwx 10 francis cis 2048 Aug 5 15:39 newsw

-rw-r--r-- 1 francis cis 153238 Jul 10 16:27 unx_staff.lis

-rw-r--r-- 1 francis cis 458473 Jul 10 16:27 unx_students.lis

Those lines that begin with a "d" indicate directories (e.g., "Mail" and "bin" above) and those that begin with a "-" are files (e.g., "forward" above). The number near the center of each listing (e.g., "153238" for "unx_staff.lis") is the size of the file in bytes. Finally, the name of the file or directory is at the far right of the listing (e.g., "newsw").

If there are a great deal of files in the current directory, you can limit the listing to a select group of files by setting criteria for the ls command. For example, ls a* would list only those files that begin with the lowercase letter "a."

To list files in your local directory (i.e., where you are FTPing from), the command will vary depending on which FTP client you are using. Common ones include lls (local listing), ldir (local directory), and !ls -l (the ! executes a command on your local computer). If none of these work, check help while at the "FTP>" prompt for a list of available commands.

CHANGING TO A DIFFERENT DIRECTORY

Quite frequently, you will want to transfer files to or from a directory that is not the default directory you logged into. To change to a different directory, you will use the cd command. For example, to change to the "manpgasc" directory in the listing above, you would type cd manpgasc. Type cd .. to go to the parent directory of the current directory. Another option is to enter an absolute path name such as cd /home/staff/cis/francis. Following are some examples of changing the current directory:

cd manpgasc

Changes to the manpgasc directory in the current directory

cd ..

Changes to the parent directory of the current directory

cd /home/staff/cis/francis

Changes to the directory /home/staff/cis/francis

Once you have changed to the new directory, use the ls command will list the files in the new directory.

As with listing files in a local directory, the commands for changing directories also varies depending upon the FTP client you are using. The two most common options are lcd and !cd. Consult help in FTP for the specific command in your FTP client.

ASCII AND BINARY FILES

Files can either be stored as ASCII or binary files. ASCII files are typically text files created by programs such as vi or pico. ASCII files contain only 7-bits of data per character while binary files are composed of 8-bit characters. Types of binary files include applications, word processor documents, graphic files, and most other types of files. Most documents generated on a PC or a Mac are binary files.

When transferring files with FTP, you need to set whether to transfer the file as ASCII or binary. If you are unsure which method to use, transfer the file using binary mode. ASCII mode should typically be used for text files and files ending with ".uu" or ".hqx." To set ASCII mode, type ascii while connected to an FTP server. For binary mode, type binary. To determine which mode you are in, type type.

TRANSFERRING FILES

Once you have connected to the remote FTP server, logged in with a valid user name and password, set the appropriate local and remote directories, and set the correct transfer mode (ASCII or binary), you are ready to transfer files. To transfer files to the FTP server from where you logged in from, use the send command. To transfer files from the FTP server to where you logged in, use the recv command. Using either send or recv, you specify the name of the file you want to transfer. For example, to send a file named "sample" from the local computer to the FTP server, you would type send sample. Some FTP clients allow you to use wildcards such as "*" to transfer many files at once, others do not.

Depending on the size of the file being transferred, the time needed to transfer the file can take a second to several hours. Gonzaga's Internet connection is sufficient to transfer most files in under five minutes unless the file is very large. If transferring files between two computers on GUNET, the transfer time will be even shorter. If transferring files over a modem, transfer times can be several hours for large files.

If you need to transfer additional files to or from the same FTP server, change the directories and file types as needed and then transfer the files. There is no limit to the number of times that the directory and file type can be changed in a single session.

If desired, a file transfer can usually be canceled by pressing Control-C.

DISCONNECTING FROM AN FTP SERVER

When you have completed transferring files to or from the FTP server, you will need to disconnect. For command line users, this is done using the command quit. GUI users will normally have a button or menu option to close the connection.

FOR ADDITIONAL HELP

When you are connected to an FTP server, you can enter the command help for a list of commands. Typing help command (e.g., help recv) will usually provide some additional information on that specific command. While logged into a UNIX server such as Barney, you can enter man ftp at the command prompt ("[username]$" on Barney), for detailed information on the use of FTP.

FTP COMMANDS - QUICK SUMMARY

! [command]

Available in some FTP clients. Used to invoke a command that is normally only available from the command prompt. For example, !ls invokes the ls command on the local computer to list files in the current directory.

append local [remote]

Appends the contents of the local file to the end of the remote file.

ascii

Set ASCII transfer mode. Used for text, HQX, and uuencoded files.

binary

Set binary transfer mode. Used for graphics, programs, and most other files other than those listed under ascii.

bye

Close the connection to the FTP server and exit. Same as quit.

cd [remote-directory]

Set the current remote directory to the specified directory.

close

Disconnect from the FTP server but don't exit the FTP software.

delete remote-file

Deletes the specified remote file if user has required permissions.

dir [remote-directory]

List the contents of the specified remote directory. If no directory is specified, list the contents of the current remote working directory. Same as ls.

help [command]

Displays information concerning the specified command. If no command is specified, help lists the available commands.

lcd [local-directory]

Available in some FTP clients. Change the current local directory to the directory specified.

ls [remote-directory]

Same as dir.

open ftp-server

Open a connection to the specified FTP server. FTP must already be running and no connection currently established.

pwd

Display the name of the current working directory.

quit

Disconnect from the FTP server and exit the FTP software.

recv remote-file

Copy the specified remote file to the local working directory using the current transfer mode (binary or ASCII).

send local-file

Send the specified local file to the remote working directory using the current transfer mode (binary or ASCII).

size remote-file

Display the size of the remote file.

status

Show the current status of the FTP client.

user user-name

Log into an already open FTP server as the specified user.