Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sunybcs!boulder!hao!noao!arizona!whm From: whm@arizona.edu (Bill Mitchell) Newsgroups: comp.unix.questions Subject: Re: Mail - How can I quickly print a mail msg? Message-ID: <1858@megaron.arizona.edu> Date: Wed, 5-Aug-87 05:45:36 EDT Article-I.D.: megaron.1858 Posted: Wed Aug 5 05:45:36 1987 Date-Received: Fri, 7-Aug-87 06:55:55 EDT References: <4533@nsc.nsc.com> <15330@teknowledge-vaxc.ARPA> Organization: U of Arizona CS Dept, Tucson Lines: 108 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); }