Programmatic Mail reader

Barton E. Schaefer schaefer at ogicse.ogc.edu
Sun Jul 29 07:35:48 AEST 1990


In article <1990Jul26.155303.15563 at mips2.cr.bull.com> peters at mips2.cr.bull.com (Dan Peters) writes:
} 
} 	This is my first post to this newsgroup, I hope it is appropriate.
} What is the easiest way to programmaticly do the following:
} 
} 	read mail,
} 	dump it to a file (i.e. log)
} 	delete the messages read (so they arn't logged again),
} 	quit mail

I'm not sure what you mean by the first step ("read mail") -- does that
mean you want to see each message before it gets saved?

If you have mush 7.1 available, that would be:

    #!/usr/local/bin/mush -F!
    unset hold
    set alwaysignore = pipe
    pipe * /usr/bin/pg
    save * dlog
    quit

You could also get a little fancier:

    #!/usr/local/bin/mush -F!
    unset hold
    if redirect		# Don't display if stdin is not a tty
	:n | save dlog		# save new mail only
    else
	set alwaysignore = pipe
	:n | /usr/bin/pg | save dlog	# print & save new mail only
    endif
    quit

Mush is available from the comp.sources.misc archives.
-- 
Bart Schaefer						schaefer at cse.ogi.edu



More information about the Comp.unix.questions mailing list