shawn@mit-eddie.UUCP (Shawn McKay) (06/23/85)
Ever wish the mailer would tell you when you get mail? Well, here is a Q&D hack to give you just that wish. Enjoy! ----------- Cut here and the tty might be hurt ------------- /* * Notify user of new mail; * * CopyRight (c) 1985 Shawn F. Mckay, All Rights Reserved. * * Permission is granted for NON-PROFIT use of any kind. * * Date: 15-May-1985 * Author: Shawn F. Mckay (mit-eddie!shawn) */ #include <stdio.h> #include <signal.h> #include <sys/types.h> #include <sys/stat.h> #define BELL (037 & 'G') int quit (); long touched(); char *getlogin(); char uname[80]; /* * Format: * * % mailer [sleep-time-in-seconds] */ main (argc, argv) int argc; char **argv; { int fh = 0; int Sleep_t = 45; long when = 0; long now = 0; char *temp = NULL; char fname[80]; register int i = 0; if (argc > 1) Sleep_t = atoi (argv[1]); fh = fork(); if (fh) exit (-1); if ((temp = getlogin()) == NULL) { printf ("%s: Unable to find your username, aborting.\n", argv[0]); exit (-1); } else strcpy (uname, temp); sprintf (fname, "/usr/spool/mail/%s", uname); signal (SIGHUP, quit); for (i=SIGINT;i < SIGPROF+1;++i) signal (i, SIG_IGN); when = touched (fname); for (;;) { sleep (Sleep_t); if (strcmp (uname, getlogin())) exit (-1); if ((now = touched (fname)) == 0) continue; if (now != when) { when = now; msg (); } } } /* * Touched: Return last access time */ long touched (fname) char *fname; { struct stat st; if (stat (fname, &st) == -1) { printf ("The file \"%s\" was not found.\n", fname); printf ("Mail watch is now terminated.\n"); exit (-1); } if (st.st_size < 1) return (0); return (st.st_mtime); } msg () { printf ("\n%c[New mail has arrived for %s]\n", BELL, getlogin()); return (1); } quit () { exit (0); }
jordan@ucbvax.ARPA (Jordan Hayes) (06/25/85)
Why is it that all of this stuff (don't get me wrong, I grab a lot of it and use some of it too!) ASSUMES that we all want the BELL char to be a ^G ?? You know there *are* some of us out here that use a visual bell and reflect this in our termcaps... What's the big deal about checking for the bell character in a term entry from my environment ?? I'm only looking for a little consideration... No, I'm not angry (at least not enough to stop subscribing to net.sources), but maybe y'all should think about the minorities every once in a while... /jordan ------- ARPA: jordan@ucb-vax.BERKELEY.EDU UUCP: jordan@ucbvax.UUCP WARHEADS: 37' 52.29" N 122' 15.41" W
wombat@ccvaxa.UUCP (06/29/85)
Alternatively, on Berkeley systems, you can use biff(1) or set the csh(1) $mail variable. (Yes, biff insists on beeping and won't flash your screen.) For csh, put a line like set mail=(10 /usr/spool/mail/$user) in your .cshrc to have csh check your mailbox every 10 minutes or at your next prompt, whichever is later. If there's new mail, you get a little 'You have new mail.' message. "When you are about to die, a wombat is better than no company at all." Roger Zelazny, *Doorways in the Sand* Wombat ihnp4!uiucdcs!ccvaxa!wombat
gm@trsvax (07/02/85)
> For csh, put a line like set mail=(10 /usr/spool/mail/$user) in your .cshrc > to have csh check your mailbox every 10 minutes or at your next prompt, > whichever is later... Uh, that first value is in seconds, not minutes. 10 minutes is the default. ------------------ "I love the smell of Napalm in the mornings..." George Moore (gm@trsvax)
shawn@mit-eddie.UUCP (Shawn McKay) (07/06/85)
<* I didn't want this line anyway! *> *Please*, enough! I have received 25+ messages telling me about biff(1), csh(1), and sysline(1), all of which I don't like, nor do I wish to use. biff(1): Does a chmod on my tty so comsat can kill my whole screen and bother me to no end. I didn't want that. csh(1): Notifies me only on command, hence, if I relax and watch TV, I only wish to glance at my terminal to see if I have any mail, after all, my system stands single user most of the time. (not mit-eddie, futura). sysline(1): Does not work on any terminals I have access too. As I have seen, it's a nice program, too bad it's got such limited terminal support. *Please* I posted that source as a service to users who might wan't something less then comsat, but more then the C shell. I do not wish to hear about my options, though the thought is appreciated. Thank you for your time. -- Shawn F. Mckay Uucp: mit-eddie!shawn Arpa: Shawn at Mit-Mc
broome@ucbvax.ARPA (Jonathan C. Broome) (07/07/85)
[ burp ] Here is a simple routine you can use wherever you want to beep the terminal without annoying people like Jordan (who has a terminal that chokes on ^G!) It checks for a visual bell capability in $TERMCAP and uses visual bells instead of control G if the terminal is capable, without dragging in the whole term{cap,lib} library. Note that is doesn't use stdio, you may want to change this for your particular application. =========================================================== Jonathan C. Broome University of California, Berkeley UUCP ...!ucbvax!broome ARPA broome@ucbvax.ARPA =========================================================== ============================================================================== /* * beep.c --- demo program for the `beep()' routine. * * Written by Jonathan C. Broome (broome@ucbvax.Berkeley) to * keep Jordan Hayes (jordan@ucbvax.Berkeley) happy - his dumb * terminal chokes on ^G !!! * * Checks for visual bell (vb) string in termcap and uses it if * found, else uses the normal ^G (\007). * * Feel free to use this code wherever, it is in the public domain. */ #define isdigit(c) ('0' <= c && c <= '9') #define NULL 0 main () { beep (); exit (0); } beep () { char *getenv(); char *termcap; char *vb; char vbuf[256]; if ((termcap = getenv ("TERMCAP")) == NULL) { write (1, "\007", 1); return; } vb = vbuf; while (*termcap != NULL) { /* find the vb string */ if (strncmp(termcap, "vb=", 3) == 0) { termcap += 3; while (*termcap && *termcap != ':') *vb++ = *termcap++; break; } *termcap++; } *vb = '\0'; if (!*vbuf) /* didn't find a vb string */ write (1, "\007", 1); else translate (vbuf); } /* * A nice hokey routine to handle printing a (simple) termcap vb string. * Note that it doesn't understand any of the `%' conversions, but what * terminals have parameters in the vb string anyway??? */ translate (buf) char *buf; { register char *i; int val = 0; i = buf; while (*i) { if (*i == '^') { /* turn ^X to the real thing */ val = *++i - '@'; write (1, &val, 1); i++; val = 0; } else if (*i == '\\') { switch (*++i) { /* all the meta-escapes */ case 'E': write (1, "\033", 1); i++; break; case 'r': write (1, "\r", 1); i++; break; case 'n': write (1, "\n", 1); i++; break; case 'b': write (1, "\b", 1); i++; break; case 'f': write (1, "\f", 1); i++; break; case 't': write (1, "\t", 1); i++; break; case '\\':write (1, "\\", 1); i++; break; default: /* or octal form */ while (*i && isdigit (*i)) val = val * 8 + ((*i++) - '0'); val &= 0177; /* strip the high bit */ write (1, &val, 1); val = 0; break; } } else /* normal character */ write (1, i++, 1); } }