home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1985 < prev    next >
Internet Message Format  |  1990-12-28  |  2KB

  1. From: davidsen@sixhub.UUCP (Wm E. Davidsen Jr)
  2. Newsgroups: alt.sources
  3. Subject: Screen blanker for SCO Xenix
  4. Message-ID: <2149@sixhub.UUCP>
  5. Date: 23 Oct 90 23:05:35 GMT
  6.  
  7. Here is a screen blanker for Xenix. It needs some magic escapes in SCO
  8. ANSI consoles, and the "security" in SCO UNIX keeps you from getting any
  9. useful info from who (maybe root will work), but it works well on that
  10. one system.
  11.  
  12.   Select a screen with no getty on it, and this program will change to
  13. that screen and blank it (including the cursor).
  14.  
  15. #!/bin/sh
  16. # shar:    Shell Archiver  (v1.27)
  17. #
  18. #    Run the following text with /bin/sh to create:
  19. #      scrnblank
  20. #
  21. sed 's/^X//' << 'SHAR_EOF' > scrnblank &&
  22. X#!/bin/sh
  23. X
  24. X# blank screen for Xenix (@(#)scrnblank - v1.2, 10/23/90 16:12:22)
  25. X
  26. X# this is the screen number for the blank screen
  27. X#    it should not be in use, preferably without a getty,
  28. X#    since the cursor is not restored. ie. tty07 would be 7
  29. XBLANK_SCR=7
  30. X
  31. X# This is the time to wait in minutes. 
  32. X#    It may be set from the command line, too
  33. Xif [ $# -eq 1 ]
  34. Xthen    WAIT=$1
  35. Xelse    WAIT=5
  36. Xfi    #
  37. X
  38. X# Logic:
  39. X#    the output of "who -u" is scanned to see if all console
  40. X#    logins are over N minutes unused. Then the screen is blanked
  41. X#    by setting cursor off and doing a clear screen.
  42. X#    This program must be run from a tty
  43. X
  44. Xwho -u |
  45. Xawk '
  46. X$2 ~ /tty[01][0-9]/ {
  47. X  # Get the time field
  48. X  time=substr($0, 38, 5)
  49. X  if (time == "old") continue
  50. X  split(time, xtime, ":")
  51. X  idle = 60*xtime[1] + xtime[2]
  52. X  if (WaitStart < idle) continue
  53. X  Active = 1
  54. X}
  55. X
  56. XEND {
  57. X  # really ugly way to change screens
  58. X  if (!Active) {
  59. X    # form the device name
  60. X    OutDev=sprintf("/dev/tty%02d", BlankScrn)
  61. X    # switch to the screen for blank use
  62. X    printf("\r\033[%02dz", BlankScrn-1) > OutDev
  63. X    # cursor off, CLS
  64. X    printf("\r\033[=14;10C\f", BlankScrn) > OutDev
  65. X  }
  66. X}' WaitStart=$WAIT BlankScrn=$BLANK_SCR -
  67. SHAR_EOF
  68. chmod 0555 scrnblank || echo "restore of scrnblank fails"
  69. exit 0
  70.  
  71. -- 
  72. bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
  73.     sysop *IX BBS and Public Access UNIX
  74.     moderator of comp.binaries.ibm.pc and 80386 mailing list
  75. "Stupidity, like virtue, is its own reward" -me
  76.