<<

. 45
( 69 .)



>>

13
INSTALL AND USE INTERNET APPLICATIONS



The mail command is also very helpful for use
While the mail command is useful, most UNIX
within scripts. For example, if you write a script to
users today prefer to use more versatile tools for
routinely check disk space, you may want the script
sending and receiving e-mail. The simple mail
to send the results of the disk check to you via
command, after all, cannot properly display
e-mail. You can use a line of code such as df “k |
e-mail that arrives in HTML format or allow you
to fetch and use attachments. The mail mail “s "disk usage" user@mydomain.org
in a script that runs once a day through cron to
command was created before HTML and
remind yourself to look at your disk space.
attachments were used in e-mails.
Even so, the mail command continues to
provide a service. For example, simple e-mail
messages sent from the command line can help
you to determine whether a mail server is
working.
Mail files, typically thought of as inboxes, are
stored in /var/mail. Each user on the system
with pending mail will have a single file in this
directory. The inbox for user would be
/var/mail/user.




– The mail system presents – The mail system displays
¤ Press Return and read the
READ A MESSAGE
you with a list of waiting first message. your messages. Typing q will
„ Type mail and press messages. exit mail.
‹ Type the number 2 and
Return.
press Return to read the next
message.



219
UNIX FOR MAC



LOOK AT YOUR MAIL FILE
will indicate the start of the message you received from

Y
ou can examine your Unix inbox without using
Gumby on that date. Each message in your inbox will begin
commands, such as mail or mail clients like Mac OS
with a line that has this form. No other lines in your inbox
X's Mail, by locating and displaying your mail file in
will begin with the word From followed by a space. These
your file system. Any time your mail setup does not appear
lines allow mail clients to determine where each message
to be working properly, knowing where and how to
starts. The message header lines that begin with tags such
examine this file will help you determine whether mail is
as Date:, From:, To:, and Subject: come next and are
arriving as it should.
followed by the text of the message that was sent to you.
The end of each message is only indicated by the beginning
To view your e-mail inbox, you should move into the
of another message or the end of the file.
/var/mail directory. This folder will contain a mail file for
each user on your system who has mail in his or her inbox.
If you send a message to yourself on the command line, using
Even if you have 300 individual messages, your inbox will
a command such as echo testing | mail user, you
consist of a single file. Each message in this file will begin
should see the size of your inbox increase, the timestamp
with a From line that includes the sender and the time and
on the file to change, and the content of this message
date that the message arrived. For example, the line From
added to the bottom of your mail file.
gumby@example.org Mon Feb 17 15:30:02 2003




LOOK AT YOUR MAIL FILE




– The top of your mail file
„ Type cd /var/mail and press ¤ Type ls “l and press ‹ Type more followed by the
Return. Return. name of your mail file, such displays.
as user, and press Return.
– A listing of mail files on
your system displays.



220
13
INSTALL AND USE INTERNET APPLICATIONS




FETCH E-MAIL FROM OTHER SERVERS
that only the individual user can read this file. In fact,

Y
ou can fetch e-mail from remote servers using the
fetchmail warns you if the permissions on the file are not
fetchmail tool. Fetchmail is a retrieval and forwarding
set to 710. This means that the owner has read, write, and
tool that supports all of the important protocols for
execute permission, while the group has only execute
retrieving mail from an e-mail server. These include the most
permission, and no one else can access the file.
popular protocols ” POP3 and IMAP ” as well as a number
of others: POP2, RPOP, APOP, KPOP, ETRN, and ODMR.
Storing the password in the file saves you from having to
enter it each time you use fetchmail. This also allows
Like many tools, fetchmail uses a configuration file,
fetchmail to automatically run through cron for daily or
.fetchmailrc, to store information about your accounts. You
more frequent downloads.
can add lines like the following to your .fetchmailrc file:
Your system must be running sendmail for fetchmail to
poll mail.mailserver.org protocol POP3 user
work properly. Fetchmail works by transferring the mail to
nici password worx4me is noh
the smtp port on your local system. If you are not using
sendmail, you can change your .fetchmailrc file to use
In this example, nici is the username for the remote
procmail instead by making it look like this:
account, while noh is the local user. The server you check
for downloadable e-mail is called mail.mailserver.org. As
poll mail.mailserver.org protocol POP3 user
you can see, the password appears in clear text. For this
nici password worx4me mda "/usr/bin/procmail
reason, you must set permissions on the .fetchmailrc file so
-d noh"

FETCH E-MAIL FROM OTHER SERVERS




‹ Type >> /var/log/fetchmail ¤ Type 11 23 * * *
USE FETCHMAIL ON RUN FETCHMAIL THROUGH CRON
THE COMMAND LINE 2>&1 and press Return. /sw/bin/fetchmail -a >>
„ Type crontab -e and press
„ Type fetchmail -v followed /var/log/fetchmail 2>&1
– Fetchmail downloads your Return.
in your crontab file.
by a space. mail from the remote server.
– Your crontab file opens.
– Your crontab file updates,
¤ Type --keep -a followed by
and fetchmail runs every
a space
night at 11:11 P.M.
221
UNIX FOR MAC




INSTALL PINE
The first time you run pine, it creates a configuration file in

P
ine is a text-based e-mail program that has been in
your Home directory called .pinerc. This file allows you to
use on UNIX systems for many years. You can install
modify a number of configuration parameters, such as how
pine on your Mac OS X system using Fink or
your name appears in messages that you send. Like most
FinkCommander. Otherwise, you can download pine from
UNIX configuration files, the .pinerc file contains numerous
www.Washington.edu/pine/getpine. You can then
comments; any line starting with a # symbol is a comment.
uncompress and untar the installation file as is described in
Chapter 12.
To make pine easy to use, you should ensure that it is on
your search path. This allows you to start pine by typing
To create the pine application, you can type build osx. This
pine on the command line. You can verify that pine is on
command takes the place of the normal make command
your search path by typing which pine. This command
and builds a pine binary for your Mac OS X system. When
returns the full path to the pine executable.
the build process is finished, you have a directory
containing the pine binary along with a series of other
Some of the other tools that are compiled along with pine
programs that you can copy to other locations on your
are useful if your system is to act as a mail server. The
system. You can refer to the README file for directions that
imapd, ipop2d, and ipop3d tools are servers that allow mail
may pertain to your installation.
clients to download e-mail. These tools support the IMAP,
POP2, and POP3 protocols, respectively.

INSTALL PINE




– A warning may appear ¤ Type the name of your
INSTALL PINE WITH FINK INSTALL PINE FROM A TAR FILE
saying Fink failed to locate TAR file or pine* and press
„ Type sudo fink install pine „ Type tar xvf followed by a
the software. Return.
and press Return. space.
– This command extracts the
contents of your TAR file.



222
13
INSTALL AND USE INTERNET APPLICATIONS




Pine, by default, stores diagnostic information in
You can start pine with a new .pinerc file two
files called .pine-debug1, .pine-debug2 and so on.
ways. You can remove your current file by typing
These files might prove to be of some interest to
rm .pinerc in your home directory. When you
you, but they are of no value. The easiest way to
start pine the next time, it will greet you as if you
turn off this feature is to add the line alias pine
had never used the program, setting up a brand
"pine “d 0". to your .tcshrc file that sets the debug
new .pinerc file for you in the process.
level or pine to 0. The next time you log on or type
Alternately, you can type the command pine
source .tcshrc, the .pine-debug files will no longer
“conf > .pinerc in your home directory. This
be created. Remember that you have to type ls “a
pipes the output of the pine “conf command,
to list files that begin with a period.
which generates the settings in a default .pinerc
file to the file you specify.




– The pine welcome page
‹ Type cd and the name of › Type ./build osx and press ˇ Type bin/pine and press
your new directory, and press Return. Return. appears.
Return.
– This command builds the
pine software for Mac OS X.




223
UNIX FOR MAC




<<

. 45
( 69 .)



>>