mskucherawy@watmath.waterloo.edu (Murray S. Kucherawy) (07/05/90)
Hi there - I'm new to mush but I'm very impressed with what I've seen thus far. I'd like to set up something in my .mushrc that behaves much like vacation does, but what I want to do is to perform a command if mail has arrived in my spool file from a particular user, and I can't seem to do it with what I'm trying. Can I pipe the output fromo a "pick" to a variable, and then see if the variable is non-zero? When I try such things, I get errors. Any takers? ============================== Murray S. Kucherawy ========================== Motorola Canada, Ltd. Communications Division, Toronto [on work term] University of Waterloo, Ontario, Canada 2A Math (Comp Sci/Pure Math) Internet: murray@motto.UUCP (work) mskucherawy@watmath.UWaterloo.ca (UW) UUCP: uunet!utai!lsuc!motto!murray uunet!watmath!mskucherawy
schaefer@ogicse.ogc.edu (Barton E. Schaefer) (07/05/90)
In article <1990Jul4.232345.26143@watmath.waterloo.edu> mskucherawy@watmath.waterloo.edu (Murray S. Kucherawy) writes: } } I'd like to set up something in my .mushrc that behaves much like } vacation does, but what I want to do is to perform a command if } mail has arrived in my spool file from a particular user, and I } can't seem to do it with what I'm trying. Can I pipe the output } fromo a "pick" to a variable, and then see if the variable is non-zero? } When I try such things, I get errors. You can't do this from .mushrc in the normal sense, because the folder has not yet been loaded at the time the .mushrc file is read. This is probably the source of your errors. Instead, you must either use the "source" command to read the file or you must use the -F option of mush (also called -source) to cause the file to be read after the folder is loaded. I have used the following script; the #! line makes it possible (on a BSD system) to set execute permissions on the script file and run it directly. #! /usr/bin/mush -inF! # # Script to clean up my mailbox while I'm away. The -i option above makes # "quit" and "folder" fail if new mail has arrived; see notes below. # cd # Make sure we're in my home directory. :n | set new # Record which messages are new, if any. # # If there are new messages, toss out stuff I don't want to bother with # if $?new pick -r $new @MUSH | d pick -r $new @PATCH | d pick -r $new @DOS | d # # If this is the spool file, clean up some stuff # if $thisfolder =~ */mail/$user # Omit deleted messages from the search with {`:d`} pick -i -r $new {`:d`} daemon | d | set ret if $?ret # Avoid "save" so the message will appear "new" mail -f $ret $home/returned-mail unset ret endif pick -i -r $new {`:d`} postmaster | d | set ret if $?ret # Avoid "save" so the message will appear "new" mail -f $ret $home/returned-mail unset ret endif endif endif # # If this isn't already the returned-mail folder, clean that too # if $thisfolder:t != returned-mail if $?new # # Retag new messages as old; don't change deleted/unread status! # flags $new + O unset new endif if -e returned-mail # # If new mail has arrived, this folder command will not change # folders. That's intentional, since all we do is re-run the # mail-agent script and pick up the new mail that just arrived. # folder -N returned-mail source mail-agent endif quit source mail-agent # If quit failed because of new mail, try again endif # # Now we must be in the returned-mail folder. # if $?new pick -r $new -e "---start beef" | d pick -i -r $new {`:d`} -s deferred | d pick -r $new {`:d`} "part . of . sent" | d pick -r $new {`:d`} mush-users | d pick -i -r $new {`:d`} perl | set perl if $?perl save $perl perl-digest | d unset perl endif unset new # In case of recursive call endif exit # From the script, not the program -- Bart Schaefer schaefer@cse.ogi.edu