File transfer between two computers

(See also mail.sas FAQ.)

Users who work in a heterogeneous environment, using different machines and systems, often need to transfer files back and forth between computers. For example, if you used a PC to write a document, you might want to transfer a copy to cattell, so that you can print it on our laser printer. Or you might have your resume written on a Mac and want to transfer it to cattell so that you can e-mail copies of it to people. You can even use our system as an intermediate node to transfer your file between Macs and PCs. Users can also make copies of the source code of programs from other computers, bring them over to cattell, compile and run them. All of this can be done using the file transferring facilities that cattell offers.

This section first contains an overview of file types, then discussion of three ways of transferring files: ftp, scp, and fetch (a program for the Macintosh only).

Ascii and binary

Most ways of transferring files give you these two options (or something like them). The difference is complex. It has to do with the way in which bytes are represented on different kinds of computers. Ascii transfer is typically used for ascii or "text" files. These are files that use letters, numbers, and standard punctuation. All of these characters can be represented in a code using numbers from 0 to 127, the standard ASCII code. This is the kind of text used in email messages (without coded attachments), in text editors such as emacs, and in the "text" output of word processors such as Word. You do not need to use ascii transfer for ascii files, but often it is best. For example, between a PC and cattell, characters at the ends of lines are different if you do not use ascii transfer, and some editors and word processors will have trouble with the ends of lines. So, in sum, it is generally a good idea to use ascii mode for simple test. Feel free to experiment, though.

ASCII FILES ARE PARTICULARLY USEFUL WHEN YOU WANT TO SEND A TEXT TO OTHER PEOPLE AND YOU ARE NOT SURE THAT THEY USE THE SAME KIND OF WORD PROCESSOR THAT YOU USE. Consult the help menu of your word processor (or spreadsheet, etc.) to learn how to make ascii output. It is often called "text output".

Binary transfer is used when you want to transfer a file exactly as is. This is what you should use for zipped (compressed) files, computer programs, the usual files produced by word processors, or data files produced by statistical programs and spreadsheets. (These are distinguished from the input files, which are typically ascii.) These files are generally useless except on the computer for which they are designed. For example, if you wrote a program that is now on your PC and you want to give it to someone else with a PC, you can upload the program in binary mode and the other person can download it in binary mode, and it will run on the other PC. The same is true for word processor files and Systat .sys files. None of these will be of any use on Cattell, however. Cattell just functions as a storage site for the exact program.

Binary transfer should always be used when you are downloading software from a remote site, e.g., a new version of Netscape.

FTP (File Transfer Protocol)

While on cattell, you can transfer files back and forth between different systems over the network. The command is ftp. For more information on ftp, please refer to the man pages. Ftp programs are now available for PCs too. Penn provides a well known version WS_FTP (or WS_FTP32) for Windows (Windows95). Other ftp programs for PCs are available and sometimes are included in terminal software. WS_FTP is menu driven, so you do not need to read what follows in order to use it. FTP is also part of most browsers, such as Netscape. You can go to an ftp server by starting the URL with "ftp://" intead of the usual "http://". Many computers have well organized "ftp sites" for the purpose of storing things for other people to get. For example, Behavioral and Brain Sciences has an ftp server for articles.

To use ftp from cattell to another computer, such as mail.sas, simply type ftp mail.sas. You will then be asked for a login name. For mail.sas, you must have an account, so you would use your login name and password (when asked). For other computers that act as sites, you can use the name "anonymous". (Usually you are told this.)

Once you are connected, you can type "help" to see the commands you can use. Standard ones are "get FILENAME" to get a file, "cd DIRECTORY" to change directory ("cd .." to move back to a previous directory), "put FILENAME" to send a file, and "dir" to see a directory listing. Sometimes a site has a file called INDEX or README. You can "get" this, then temporarily exit ftp with ctrl-z, then browse it (e.g., less INDEX), and then go back to ftp by saying "fg" (for "foreground" - undoes ctrl-z). Don't forget to "quit" or "exit" when you are done.

If you have file(s) that one or more users at other systems would like to have, the best way is to put the file(s) into a courtesy (public) account, then users on other systems can simply ftp them from this public account. Contact the System Administrator (manager@psych) if you want to do this. There is a "courtesy account" on many systems, it is usually called "anonymous". On cattell, we do have such a courtesy account, with username "anonymous". This "anonymous" username has a home directory "~ftp" and that is where you can deposit your files for others to access. You can use anonymous ftping to get public-domain software from systems that are used as archives of network software. The "anonymous" public account is usually where those archives are stored.

Warning: ftp allows two different transfer modes-- text and binary. To transfer regular text files, use the "text" mode, but to transfer non-text files, precompiled object codes, etc, you will need to set ftp to binary mode before starting the transfer (to do this, within the ftp interface, type in binary).

Since ftp sends files over the network, and the network is not 100% reliable, file transfers are not always successful. You do not have control over the network, but when you are doing the transferring, you can usually tell whether the transfer is completed or not by the report returned by ftp which contains the size of the original file and the copied file. If they match, the transfer is usually successful. If files to be transferred are very large, ftp will spend more time transferring which leads to vulnerability and problems. The best way is to compress the file(s) into one file and transfer. We will introduce a better way to bundle several large files together into one file in section 10 (FAQ's).

SCP

Ftp is insecure because your password is not encoded. Scp gets around this problem. Scp is currently standard only on Unix and Linux. So you can use it to copy files from one Unix/Linux machine to another. You use it just like the Unix cp command, except that you indicate the source or destination name before a colon. For example:
scp myfile baron@cattell.psych.upenn.edu:
scp myfile baron@cattell.psych.upenn.edu:public_html/
scp baron@cattell.psych.upenn.edu:myfile .
scp baron@cattell.psych.upenn.edu:myfile myfile2
The first example uploads myfile from my current computer to my home directory on Cattell. The second uploads it to my public_html directory. The third downloads it. The dot means "here". The fourth downloads it and renames it.

Scp will overwrite files of the same name without asking. It will ask for your password each time you use it. You can also use it to copy entire directories, with wildcards, etc. See man scp for details. If you use it a lot, you can make an alias, e.g., for your .cshrc file on your (Linux) desktop:

alias scpup scp !$ baron@cattell.psych.upenn.edu:
alias scpdown scp baron@cattell.psych.upenn.edu:!$ .

Fetch for the Mac

Fetch is an almost-trivial-to-use Macintosh program. Double-click on Fetch, and you'll be prompted for a host (psych.upenn.edu), a username and a password. Fill these items in, ignoring any other fields. Click on OK.

Once you're connected, you can click on any file, then click on the "Get File" button to pull it from cattell onto your Mac. Click the "Put File" button to get a dialog box which will allow you to select a file from your Macintosh to send.

Fetch is very fast, and very convenient. These is no need to disconect from cattell or even to quit any other programs to run it. Remember, you can have a number of program running at once on a Mac, and you can have as many programs communicating with cattell as you want.


Comments to baron@psych.upenn.edu