[comp.unix.questions] Mail - How can I quickly print a mail msg?

grenley@nsc.UUCP (08/04/87)

I would like to be able to print a mail message from mail.  Currently,
I save the message, then print them when I exit.  I would prefer to
just print it, without creating a file, as I don't want to keep it
around on disk.  I use 4.3bsd and csh.

Can anybody help?

Thanks, George

mkhaw@teknowledge-vaxc.UUCP (08/04/87)

in article <4533@nsc.nsc.com>, grenley@nsc.nsc.com (George Grenley) says:
> 
> I would like to be able to print a mail message from mail.  Currently,
> I save the message, then print them when I exit.  I would prefer to
> just print it, without creating a file, as I don't want to keep it
> around on disk.  I use 4.3bsd and csh.

When I used to use /usr/ucb/Mail, my .mailrc had
	alias printer '|lpr'

So to print, I'd just
	m printer
	~f
	^D

Elm and Mush both have print commands, and I expect MH also gives you a way
to print.

Mike Khaw
-- 
internet:  mkhaw@teknowledge-vaxc.arpa
usenet:	   {hplabs|sun|ucbvax|decwrl|sri-unix}!mkhaw%teknowledge-vaxc.arpa
USnail:	   Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303

whm@arizona.edu (Bill Mitchell) (08/05/87)

One day I grew tired of saving stuff into a file and then printing the file,
so I hacked Mail to allow one to "s |cmd".  I took the easy route and ignored
the problem of not being able to "s |cmd arg".  It seems to cover about 90%
of my needs.  The diffs are pretty simple and follow.  You can take them or
leave them!
					Bill Mitchell
					whm@arizona.edu
					{allegra,cmcl2,ihnp4,noao}!arizona!whm

*** /tmp/,RCSt1013587	Wed Aug  5 02:38:56 1987
--- cmd2.c	Thu May  8 11:22:01 1986
***************
*** 151,163
  		return(1);
  	printf("\"%s\" ", file);
  	fflush(stdout);
! 	if (stat(file, &statb) >= 0)
! 		disp = "[Appended]";
! 	else
! 		disp = "[New file]";
! 	if ((obuf = fopen(file, "a")) == NULL) {
! 		perror(NOSTR);
! 		return(1);
  	}
  	cc = 0L;
  	lc = 0;

--- 151,162 -----
  		return(1);
  	printf("\"%s\" ", file);
  	fflush(stdout);
! 	if (file[0] == '|') {
! 		disp = "[Piped]";
! 		if ((obuf = popen(&file[1], "w")) == NULL) {
! 			perror(NOSTR);
! 			return(1);
! 		}
  	}
  	else {
  		if (stat(file, &statb) >= 0)
***************
*** 159,164
  		perror(NOSTR);
  		return(1);
  	}
  	cc = 0L;
  	lc = 0;
  	for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {

--- 158,173 -----
  			return(1);
  		}
  	}
+ 	else {
+ 		if (stat(file, &statb) >= 0)
+ 			disp = "[Appended]";
+ 		else
+ 			disp = "[New file]";
+ 		if ((obuf = fopen(file, "a")) == NULL) {
+ 			perror(NOSTR);
+ 			return(1);
+ 		}
+ 	}
  	cc = 0L;
  	lc = 0;
  	for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
***************
*** 167,173
  		mp = &message[mesg-1];
  		if ((t = send(mp, obuf, 0)) < 0) {
  			perror(file);
! 			fclose(obuf);
  			return(1);
  		}
  		lc += t;

--- 176,185 -----
  		mp = &message[mesg-1];
  		if ((t = send(mp, obuf, 0)) < 0) {
  			perror(file);
! 			if (file[0] == '|')
! 				pclose(obuf);
! 			else
! 				fclose(obuf);
  			return(1);
  		}
  		lc += t;
***************
*** 178,184
  	fflush(obuf);
  	if (ferror(obuf))
  		perror(file);
! 	fclose(obuf);
  	printf("%s %d/%ld\n", disp, lc, cc);
  	return(0);
  }

--- 190,199 -----
  	fflush(obuf);
  	if (ferror(obuf))
  		perror(file);
! 	if (file[0] == '|')
! 		pclose(obuf);
! 	else
! 		fclose(obuf);
  	printf("%s %d/%ld\n", disp, lc, cc);
  	return(0);
  }

csrobe@icase.arpa (Charles S. Roberson) (08/06/87)

In article <4533@nsc.nsc.com>, grenley@nsc.nsc.com (George Grenley) says:
> 
> I would like to be able to print a mail message from mail.  Currently,
> I save the message, then print them when I exit.  I would prefer to
> just print it, without creating a file, as I don't want to keep it
> around on disk.  I use 4.3bsd and csh.

If you have the pipe command you can try this:

Add this line in you .mailrc file:

set cmd='lpr -P<your_favorite_printer>'

and then when you have just finished reading a message and it is still
the 'current message', type:

pipe

This is what I use for a quick print.

From what I understand, if you want a to print a message other than
the current message you must specify the whole thing.

pipe <msg #> 'lpr -P<your_favorite_printer>'

good luck,
-c


--------------------------------------------------------------------
Chip Roberson                ARPANET:  csrobe@icase.arpa
1105 London Company Way      BITNET:   $csrobe@wmmvs.bitnet
Williamsburg, VA 23185       UUCP:     ...!seismo!gmu90x!wmcs!csrobe
--------------------------------------------------------------------

allbery@ncoast.UUCP (08/09/87)

As quoted from <15330@teknowledge-vaxc.ARPA> by mkhaw@teknowledge-vaxc.ARPA (Michael Khaw):
+---------------
| Elm and Mush both have print commands, and I expect MH also gives you a way
| to print.
+---------------

Either of "show|lpr" or "lpr `mhpath cur`" will work.  I use the former.
-- 
 Brandon S. Allbery, moderator of comp.sources.misc and comp.binaries.ibm.pc
  {{harvard,mit-eddie}!necntc,well!hoptoad,sun!mandrill!hal}!ncoast!allbery
ARPA: necntc!ncoast!allbery@harvard.harvard.edu  Fido: 157/502  MCI: BALLBERY
   <<ncoast Public Access UNIX: +1 216 781 6201 24hrs. 300/1200/2400 baud>>
** Site "cwruecmp" is changing its name to "mandrill".  Please re-address **
*** all mail to ncoast to pass through "mandrill" instead of "cwruecmp". ***

roger@celtics.UUCP (Roger B.A. Klorese) (08/13/87)

In article <4533@nsc.nsc.com> grenley@nsc.UUCP (George Grenley) writes:
>I would like to be able to print a mail message from mail.  Currently,
>I save the message, then print them when I exit.  I would prefer to
>just print it, without creating a file, as I don't want to keep it
>around on disk.  I use 4.3bsd and csh.
>
>Can anybody help?

Here's an inelegant but painless solution...

In your .mailrc file, include the following:

	alias print |lpr

Then, when you have a message you wish to print, after reading it, send
it on to the mock-user "print".  If you read message 5, for example...

	& m print
        ~f 5
        ^D

(If you wish to provide this capability system-wide, put the alias in
/usr/lib/aliases instead of your .mailrc file.)
-- 
 ///==\\   (No disclaimer - nobody's listening anyway.)
///        Roger B.A. Klorese, CELERITY (Northeast Area)
\\\        40 Speen St., Framingham, MA 01701  +1 617 872-1552
 \\\==//   celtics!roger@seismo.CSS.GOV - seismo!celtics!roger