+++ /dev/null
-#! /usr/bin/env python\r
-\r
-# Print From and Subject of messages in $MAIL.\r
-# Extension to multiple mailboxes and other bells & whistles are left\r
-# as exercises for the reader.\r
-\r
-import sys, os\r
-\r
-# Open mailbox file. Exits with exception when this fails.\r
-\r
-try:\r
- mailbox = os.environ['MAIL']\r
-except (AttributeError, KeyError):\r
- sys.stderr.write('No environment variable $MAIL\n')\r
- sys.exit(2)\r
-\r
-try:\r
- mail = open(mailbox)\r
-except IOError:\r
- sys.exit('Cannot open mailbox file: ' + mailbox)\r
-\r
-while 1:\r
- line = mail.readline()\r
- if not line:\r
- break # EOF\r
- if line.startswith('From '):\r
- # Start of message found\r
- print line[:-1],\r
- while 1:\r
- line = mail.readline()\r
- if not line or line == '\n':\r
- break\r
- if line.startswith('Subject: '):\r
- print repr(line[9:-1]),\r
- print\r