[comp.mail.elm] readmsg is missing a feature

protofan@motcid.UUCP (Mike S. Protofanousis) (12/13/90)

As written, readmsg is used as follows:

     SYNOPSIS
	  readmsg [-p] [-n] [-f	filename] [-h]
	  readmsg [-p] [-n] [-f	filename] [-h] number [number ...]
	  readmsg [-p] [-n] [-f	filename] [-h] pattern

	  The -f flag indicates	that you'd rather use the file
	  specified for	the operations specified rather	than the
	  default mailbox.

readmsg should allow filename to be set as '-' so that
a mailfile can be read from standard input.

This is extremely easy to implement and does not change how readmsg works.

Only one source file needs to be changed: utils/readmsg.c (line 205)
< 	if ((file = fopen(infile, "r")) == NULL) {
---
> 	if (strcmp(infile, "-") == 0)
> 	  file = stdin;
> 	else if ((file = fopen(infile, "r")) == NULL) {

Now, you might ask, why would I want readmsg to read from stdin?

Well, I use filter quite a lot and would like to add something like this:
if (from gagme!proto and subject execute) then 
	execute "/usr/local/bin/readmsg -n -f- 1 | /bin/sh"

So, If I am logged on gagme and I mail a message to my machine with
subject execute, filter will look to see if it is from gagme!proto and
execute the readmsg command and pipe that to the shell.
This allows me to execute remote commands without ever logging on to
the remote system.

This would not be possible if readmsg did not read from standard input.

The above is just one example of why readmsg should be able to read
from standard input.  I'm sure other people can think of some other uses.


-- 
Michael Protofanousis
msp@pronet.chi.il.us