Email is a text-only medium. You cannot send email containing binary characters over the Internet. Basically, if it isn't a .txt file, you can't send it across the net. If you do, the mail may come back to you marked undeliverable, it may have all the non-text characters removed forcibly reducing your mail to a pile of individual letters, or it may just disappear when it gets to a machine which cannot gracefully handle binary characters in the mail.
Think of it like trying to mail someone a book at the US Postal office. You don't expect to slap a stamp and a mailing label on the book and have it arrive at its intended destination intact. Rather, you put the book in a box or wrap it in brown paper before putting the stamps and label on it. Likewise, you can't just drop a Word document or an Excel spreadsheet into your Internet mail box and expect it to arrive looking anything like what you tried to send.
Before you can email someone a file, you must first put it in an electronic box, or wrap it in virutal paper. There are several programs which provide you with the packing materials you need to email someone that file. Among these programs, the three most common are UUEncode, BinHex, and MIME. Each of these programs will take that binary file and encode it, using only normal ASCII (text) characters such as letters, numbers, and basic punctuation symbols. Once the file is converted to text, Internet email can handle the file smoothly, just like putting your book in a box.
Eudora, an offline mail reader which runs in Windows and on the Macintosh, handles BinHexed and MIME-encoded messages smoothly. However, before you jump to use Eudora instead of the Unix programs and utilities below, note the following:
Eudora is a mail downloader. While this means it will download and decode that file in that mail message you received, it also means it wants to download all your mail, not just that one message. It is intended to let you log in quickly, download your mail, read it and write your replies at your leisure, and then send the replies later on to minimize the time you are connected to the SGI workstation.
Eudora can be very useful if you will only read your mail from one location -- say, your office PC -- but never read it from anywhere else. If you read your email from multiple locations, like from your office and from home or from a laptop on the road, Eudora has a tendency to either download and erase mail from the SGI or download it and mark it as "read" on the SGI. This doesn't seem like much of a problem until you realize that Eudora only bothers to download new messages. Once you've downloaded them and they're marked as having been read, it is very difficult to get Eudora to download them again.
If you're not very careful, Eudora can cause you and the system some large problems.
Eudora can also send mail and easily attach files in a way very similar to Elm, but with a graphical interface instead of Elm's text interface.
UUEncode, or Unix-to-Unix Encode, was first presented to the Internet in 1980, introduced with a new variety of Unix known as BSD 4.0. It was the first binary-to-plaintext converter for the Internet, and is the most widely accessible program of this type. Since 1980 it has been a standard part of Unix. There are also DOS and Macintosh versions of this program. While it is the oldest such program, and probably the most commonly used, it has a few problems which make it impossible to get UUEncoded files through to certain parts of the Internet. Nevertheless, it is a powerful and useful tool.
UUEncoded files can be distinguished from other binary-text converted files by the beginning and end of the encoded file. A UUEncoded file will look something like:
begin
0755 filename |
The begin line contains the filename and
some other information about the file to be recreated when the encoded file is
decoded. Note that while in most cases the encoded lines all begin with
"M" that this is by no means guaranteed. The "begin"
line is the giveaway that this encoded file was created by UUEncode.
The Macintosh program BinHex, or Binary to Hexadecimal converter, was first produced in 1984. Because of similar problems to the mainly-Unix Internet network, a similar solution was created. Like UUEncode, BinHex takes a binary file and encodes it as all text characters. Almost as old as UUEncode, BinHex is widely used in the Macintosh community. It is not, however, compatible with UUEncode.
All BinHex files should end with the filename extension .hqx, though if it has been emailed to you there is no filename, naturally. It is very easy to tell a BinHex file on sight, though. They must begin:
| (This file must be converted with BinHex 4.0)
|
Notice that while UUEncode tells you the name of the file inside the encoded text, BinHex does not. The name of the file is encoded along with the file itself. Also, there is no "end of file" marker. Nevertheless, it is very easy to tell a BinHex file by that first line.
MIME, or Multimedia Internet Mail Extensions, is another encoding format similar to the above two, but is much younger and more complicated than either BinHex or UUEncode. MIME became the official Internet standard in June 1992, according to the group responsible for the Internet standards, the Internet Engineering Task Force (IETF). MIME builds on the foundations and concepts laid by UUEncode and BinHex, but adds many more abilities.
Depending on the type of file being encoded, MIME uses several different types of encoding, including Base64 which looks similar to UUEncode and BinHex, and Quoted-Printable which translates only binary characters and leaves text characters alone (thus allowing you to read most of the file as text, if it was mostly text, without decoding it first, but retains the ability to decode the file into an exact duplicate of the original as well).
MIME is also capable of encoding several files into one encoded file, allowing several files to be sent in a single email message. Each encoded MIME file typically contains some information about what sort of file is encoded. You may have noticed that Elm occasionally treats two MIME-encoded messages completely differently. It is basing its differences on the type of the encoded file, or on the encoding method used.
All MIME messages must contain several header lines, similar to the following, which may be intermixed with other headers in an email message.
Mime-Version: 1.0 |
The above is an example of the Base64 encoding. However, MIME messages do not have the problems with some sections of the Internet which UUEncode has.
MIME is still young, and because of that the number of programs which smoothly support it are few and far between. The Elm program, for instance, can do some things with MIME-encoded messages, but generally speaking handles them in a rather inelegant way. Nevertheless, MIME is now supported on Macintosh, IBM, and Unix computers, and will emerge the victor of the text-encoding programs in time because of its powerful nature and advanced features.
It is very likely that you will come across files which have been encoded using more than one style. Most common is the situation where several binhex- or uuencode-encoded files have been included in a single MIME-encoded email message (remember that MIME can attach several files to one message, or several messages into one piece of email, with any of a variety of encoding methods).
When you run across this situation, you must tear the paper off the box before you can open the box to get whatever's inside it. For example, for a uuencoded file within a MIME message, you will have to remove the MIME encoding before you can uudecode the file to get your final product.
Onestep at a time.
Before you can decode a UUEncoded message, you must first save that message to a file. See Appendix A for instructions on saving email messages from Elm to files on the SGI workstation.
Once you have the file saved in
your account and are at the Unix prompt ("< 1 biochem /people/user >"),
run the command:
uudecode filename
The uudecode program will read through the file until it finds the
begin line which marks the start of the uuencoded message. It will
decode the file, and stop at the end line.
Caveat: uudecode does not care whether the filename
it needs to create exists or not! It is up to you to check and make sure the
begin line contains a filename which does not already exist. When
you run uudecode, it will overwrite an old file with the newly decoded file
without any warning. It is a very good idea to look over the message you
intend to decode to see what file it will create.
Decoding a BinHex file is more complicated than decoding a UUEncoded file. This is mainly because of the way Macintosh computers store their files. Each file on a Macintosh has three distinct parts, or forks. These are the data, resource, and text forks. The only one a non-Macintosh computer generally cares about is the data fork. The data fork of a Word document contains the document itself. The other forks contain some extra data for the Macintosh to use. Generally this data isn't needed, but occasionally a Macintosh program will put some important information into the resource fork, rendering it unreadable to any computer other than a Mac. If you run into this situation, ask the sender of the message to save their file in a DOS format before sending it, or ask them to use MIME rather than BinHex, which should help as well. Having saved your message to a file and exited Elm as per Appendix A, the first step is to decode the BinHex "box" around the file. The command for that is:
mcvert -x filename.hqx
(remember
that all BinHex files should end in .hqx)
This will typically
produce a MacBinary file, which is really a three-part file containing the
data, resource, and text forks as discussed above. These files generally end
in .bin. You're generally only interested in the data fork, so we
will ask mcvert to extract that fork for us:
mcvert -Ud filename.bin
This will decode the MacBinary file
and produce a file whose name ends in .data, e.g.
workinfo.xls.data, which can safely be downloaded
If you want to send a file to someone else via email, you will have to encode it so it can travel safely. If you know whether the intended recipient prefers uuencoded or MIME-encoded files, use the one they prefer. Otherwise, it is probably best to send it MIME encoded, as that is the new standard for the Internet.
To encode a file which you have uploaded to the SGI via FTP or one you have on the SGI from when you decoded a mail message, you can use one of two methods.
To uuencode a file, you will need to create an encoded version of the file before sending your email. The command is:
uuencode filename filename > filename.uu
Yes, it looks a bit odd that you have to include the filename twice. The
reason for this is, uuencode needs to know what file to encode, and what to
name the file when someone decodes it. the "> filename.uu" at
the end takes the output of the uuencode command and saves it in a file named
filename.uu.
When you are writing your email message and wish to send this encoded file
along, you must press "control-R" to read the file in if you're
using Pico, or "control-x I" in Emacs to insert the file
"filename.uu" in your current message.
To MIME encode a file, you should use the "attach" feature of Elm. When you have typed a brief message and exited the editor (by pressing control-X in pico or control-x control-c in Emacs), you see a one-line Elm menu which defaults to 's' for "send message." One of the other options here is 'a' for "attach a file." Press 'a' and you will see the attachments menu. Press 'a' again to 'add' an attachment. Press 'f' to specify you're going to attach a unix file. At this point, type the name of the file you wish to attach. Press 'r' twice to return to the 'send' menu, and press 's' to send the message on its way or 'f>' to 'forget it' and try again later.
At the Index in the Elm program, move the hilite bar over the message you want to save.
Press a capital 'C' to copy the mail message to a file. Type over
the filename Elm provides, and make the filename start with "~/",
which means your directory on the SGI. (A shortcut for
/usr/people/username/) e.g., "~/william.hqx" will save
the message in the file named /usr/people/username/william.hqx.
You can then exit out of Elm by pressing 'q' for "quit".