Re: Interrupt Message
Posted in 1992
Easy enough, if I understand the question fully... Use your termcap/terminfo...at least if you have the "tput" feature on your system (if not, you can do the same thing, but it will be more terminal-dependent). Get the terminal strings for Save Cursor Location, Move Cursor, optionally Start/Stop Inverse Video, and Restore Cursor. Then all you do is: Save Cursor [location] Move to row 1, column 60 (or wherever...) [Turn on inverse video] Write a short message [Turn off inverse video] Restore Cursor [location] Occasionally, things get a bit messed up if there is output to the screen (or input from your keyboard) _exactly_ when the cursor is being moved or inverse video is being turned on, but on the whole it works pretty well. I use this scheme to check for new e-mail every 15 minutes (with a lot of other fancy code in the "tcheck" background shell script so I can kill it without knowing it's PID, checking multiple incoming mail files, checking for new News, etc.). When you log out, your background job goes away. If you want it to be created when you enter Informix, and be killed when you exit, then just have the background process create a temporary file, look for the existence of the file every time after the "sleep nnn" and before running, and then have the Informix "wrapper" script delete the temporary file on exit. Here's a slightly simplified version of "tcheck": #FUNCTION: (tcheck) Checks for new mail every nn seconds Name=`basename $0 | cut -c1-10` SO=`tput smso` #Start Standout Mode SUL=`tput smul` #Start UnderLine Mode SE=`tput rmso` #End Standout (etc.) Mode SC=`tput sc` #Save Cursor Position RC=`tput rc` #Restore Cursor (to position of last sc) if test "$TERM" = "vt100" then XSO=$SUL #use underline (optional color) for standout mode else XSO=$SO #use inverse video for standout mode fi if test -z "$1" then #assume 15 minute pause MInterval=900 else MInterval=$1 fi MMins=`expr $MInterval / 60` XInterval=`expr $MMins \\* 60` MSeconds=`expr $MInterval - $XInterval` if test $MMins -gt 0 then MEvery="$MMins minutes" fi if test $MSeconds -gt 0 then MEvery="${MEvery} ${MSeconds} seconds" fi echo "Started: `date '+%H:%M:%S'` (every $MEvery)" > $HOME/.bg_$Name chmod 666 $HOME/.bg_$Name while true do sleep $MInterval if test -f $HOME/.bg_$Name then echo "Last run: `date '+%H:%M:%S'` (every $MEvery)" > $HOME/.bg_$Name else exit 0 fi newaddr=0 if test -s $HOME/mailbox then if test -f $HOME/._mailbox then find $HOME/mailbox -newer $HOME/._mailbox -exec echo "${SC}\\007\\007`tput cup 0 63`${XSO}YOU HAVE NEW MAIL${SE}${RC}\\c" \\; else echo "${SC}\\007\\007`tput cup 0 63`${XSO}YOU HAVE NEW MAIL${SE}${RC}\\c" fi fi done #End of tcheck To run it as a background job to something like "isql", you would just create a wrapper shell script like "myisql": #FUNCTION: (myisql) Wrapper script for isql so mail can be checked for # in the background tcheck 900& #check for new mail every 15 minutes (900 seconds) isql dbname rm -f .bg_tcheck #End of myisql Cheers, Rich