home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / database / informix / 1719 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  3.7 KB

  1. Path: sparky!uunet!caen!sol.ctr.columbia.edu!emory!STL-07SIMA.ARMY.MIL
  2. From: zellich@STL-07SIMA.ARMY.MIL (Rich Zellich)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re: Interrupt Message
  5. Message-ID: <9306@emory.mathcs.emory.edu>
  6. Date: 13 Aug 92 20:38:06 GMT
  7. Sender: walt@mathcs.emory.edu
  8. Reply-To: zellich@STL-07SIMA.ARMY.MIL (Rich Zellich)
  9. Lines: 100
  10. X-Informix-List-ID: <list.1378>
  11.  
  12. Easy enough, if I understand the question fully...
  13.  
  14. Use your termcap/terminfo...at least if you have the "tput" feature
  15. on your system (if not, you can do the same thing, but it will be
  16. more terminal-dependent).  Get the terminal strings for Save Cursor
  17. Location, Move Cursor, optionally Start/Stop Inverse Video, and Restore
  18. Cursor.  Then all you do is:
  19.  
  20.    Save Cursor [location]
  21.    Move to row 1, column 60 (or wherever...)
  22.    [Turn on inverse video]
  23.    Write a short message
  24.    [Turn off inverse video]
  25.    Restore Cursor [location]
  26.  
  27. Occasionally, things get a bit messed up if there is output to the screen
  28. (or input from your keyboard) _exactly_ when the cursor is being moved or
  29. inverse video is being turned on, but on the whole it works pretty well.
  30. I use this scheme to check for new e-mail every 15 minutes (with a lot of
  31. other fancy code in the "tcheck" background shell script so I can kill it
  32. without knowing it's PID, checking multiple incoming mail files, checking
  33. for new News, etc.).
  34.  
  35. When you log out, your background job goes away.  If you want it to be
  36. created when you enter Informix, and be killed when you exit, then just
  37. have the background process create a temporary file, look for the existence
  38. of the file every time after the "sleep nnn" and before running, and then
  39. have the Informix "wrapper" script delete the temporary file on exit.
  40.  
  41. Here's a slightly simplified version of "tcheck":
  42.  
  43.   #FUNCTION: (tcheck) Checks for new mail every nn seconds
  44.   Name=`basename $0 | cut -c1-10`
  45.   SO=`tput smso`    #Start Standout Mode
  46.   SUL=`tput smul`   #Start UnderLine Mode
  47.   SE=`tput rmso`    #End Standout (etc.) Mode
  48.   SC=`tput sc`      #Save Cursor Position
  49.   RC=`tput rc`      #Restore Cursor (to position of last sc)
  50.   if test "$TERM" = "vt100"
  51.   then
  52.      XSO=$SUL       #use underline (optional color) for standout mode
  53.   else
  54.      XSO=$SO        #use inverse video for standout mode
  55.   fi
  56.   if test -z "$1"
  57.   then
  58.      #assume 15 minute pause
  59.      MInterval=900
  60.   else
  61.      MInterval=$1
  62.   fi
  63.   MMins=`expr $MInterval / 60`
  64.   XInterval=`expr $MMins \* 60`
  65.   MSeconds=`expr $MInterval - $XInterval`
  66.   if test $MMins -gt 0
  67.   then
  68.      MEvery="$MMins minutes"
  69.   fi
  70.   if test $MSeconds -gt 0
  71.   then
  72.      MEvery="${MEvery} ${MSeconds} seconds"
  73.   fi
  74.   echo "Started:  `date '+%H:%M:%S'` (every $MEvery)" > $HOME/.bg_$Name
  75.   chmod 666 $HOME/.bg_$Name
  76.   while true
  77.      do
  78.         sleep $MInterval
  79.         if test -f $HOME/.bg_$Name
  80.         then
  81.            echo "Last run: `date '+%H:%M:%S'` (every $MEvery)" > $HOME/.bg_$Name
  82.         else
  83.            exit 0
  84.         fi
  85.         newaddr=0
  86.         if test -s $HOME/mailbox
  87.         then
  88.            if test -f $HOME/._mailbox
  89.            then
  90.               find $HOME/mailbox -newer $HOME/._mailbox -exec echo "${SC}\007\007`tput cup 0 63`${XSO}YOU HAVE NEW MAIL${SE}${RC}\c" \;
  91.            else
  92.               echo "${SC}\007\007`tput cup 0 63`${XSO}YOU HAVE NEW MAIL${SE}${RC}\c"
  93.            fi
  94.         fi
  95.      done
  96.   #End of tcheck
  97.  
  98.  
  99. To run it as a background job to something like "isql", you would just
  100. create a wrapper shell script like "myisql":
  101.  
  102.    #FUNCTION: (myisql) Wrapper script for isql so mail can be checked for
  103.    #                   in the background
  104.    tcheck 900&            #check for new mail every 15 minutes (900 seconds)
  105.    isql dbname
  106.    rm -f .bg_tcheck
  107.    #End of myisql
  108.  
  109.  
  110. Cheers,
  111. Rich
  112.