3 # Print From and Subject of messages in $MAIL.
4 # Extension to multiple mailboxes and other bells & whistles are left
5 # as exercises for the reader.
9 # Open mailbox file. Exits with exception when this fails.
12 mailbox
= os
.environ
['MAIL']
13 except (AttributeError, KeyError):
14 sys
.stderr
.write('No environment variable $MAIL\n')
20 sys
.exit('Cannot open mailbox file: ' + mailbox
)
23 line
= mail
.readline()
26 if line
.startswith('From '):
27 # Start of message found
30 line
= mail
.readline()
31 if not line
or line
== '\n':
33 if line
.startswith('Subject: '):
34 print repr(line
[9:-1]),