home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / nsfast / root.10 / usr / ns-home / cgi-bin_nsfast / motd.cgi / motd.cgi
Encoding:
Text File  |  1998-08-19  |  1.3 KB  |  50 lines

  1. #!/bin/tcl
  2. #
  3. #       @(#) motd.cgi 13.2 97/12/23 
  4. #
  5. # Copyright (c) 1997 The Santa Cruz Operation, Inc.. All Rights Reserved.
  6. # THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE SANTA CRUZ OPERATION INC.
  7. # The copyright notice above does not evidence any actual or intended
  8. # publication of such source code.
  9. #
  10.  
  11. # See if the file exists
  12. if {[catch "file stat /etc/motd statbuf"]} {
  13.     echo "Content-type: text/html"
  14.     echo ""
  15.     echo "<HTML><BODY>"
  16.     echo "No /etc/motd file"
  17.     echo "</BODY></HTML>"
  18.     return
  19. }
  20. if {$statbuf(size) == 0} {
  21.     echo "Content-type: text/html"
  22.     echo ""
  23.     echo "<HTML><BODY>"
  24.     echo "Empty /etc/motd file"
  25.     echo "</BODY></HTML>"
  26.     return
  27. }
  28. if {[catch "exec /usr/ucb/hostname" hostname]} {
  29.     puts stderr $hostname
  30.     exit 1
  31. }
  32.  
  33. set buf [read_file /etc/motd] 
  34. echo "Content-type: text/html"
  35. echo ""
  36. echo "<HTML><HEAD>"
  37. echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"60; URL=http://$hostname/cgi-bin/shutd.cgi\">"
  38. echo "</HEAD>"
  39. echo "<BODY>"
  40. echo "<SCRIPT LANGUAGE=JavaScript>"
  41. set buf [split $buf \n]
  42. foreach line $buf {
  43.     regsub -all {[^A-Za-z0-9]} $line {\\&} line_esc
  44.     append nbuf "$line_esc\\n"
  45. }
  46. echo "var buf = \'$nbuf\';"
  47. echo "
  48. alert(\"\\n______________________________\\n\\nMessage of the day:\\n______________________________\\n\\n\" + buf);"
  49. echo "</SCRIPT> </BODY> </HTML>"
  50.