How do I notify X users of system shutdown?

How do I notify X users of system shutdown?

Post by David Pott » Tue, 18 Oct 1994 05:53:31



I admin a SunOS box on which most users don't perform a shell login - they
merely rexec their application to their X server (PC running X software).

I don't know how to notify these users of an impending system shutdown.  I
can get their names out of the process table (not out of who), but I don't
know the correct method for displaying a warning.

Any suggestions?

Thanks!

-------------------------------------------------------------------------------
 David E. Potter                       |                           MIS Manager

 
 
 

How do I notify X users of system shutdown?

Post by Logan Sh » Fri, 28 Oct 1994 10:55:54



>I don't know how to notify these users of an impending system shutdown.  I
>can get their names out of the process table (not out of who), but I don't
>know the correct method for displaying a warning.

Well, there are a number of options:

        1)  Send them mail.

        2)  If you can figure out where they're logged in from, then
            'rsh' to that machine and do a 'write'.  Say the user 'joe'
            is on remotely from host 'mybox'.  You'd do something like
            this:

                echo "*** `hostname` going down! ***" | rsh mybox write joe

        3)  If the user is logged in from a machine that is running rwalld
            (see /etc/inetd.conf), you can probably use rwall to send
            messages to all users on their machine.  It might give
            messages to others who don't want them, but if it's a
            departmental server or something, that might not be so bad.

        4)  Use the appropriate options to ps to make it give you the
            environment ("ps eauxww" works on many systems), then
            grok the "DISPLAY=somehost:0" portion out, and -then- run
            some kind of small X app (maybe something in Tcl/Tk, or
            xloadimage presenting a bitmap) onto that display which will
            pop up and give them the message.

        5)  Run down the hall yelling, "The server's going down!"

Of course, a lot of these ideas assume you can get the name of the
machine the user is logged in from.  If they have no shell on that
machine, that might not be easy.

A more heavyhanded (but simple) idea is to look at the
output of 'netstat' and find all the hosts connected to the machine,
and then do an rwall (or rsh'ed "wall") to each of those hosts.
In the Bourne shell, something like this:

        netstat -f inet | grep tcp |
                awk '{ print $5 }' | cut -d. -f1 |
                sort | uniq |
                while read host
                do
                        echo "**** `hostname` going down ****" |
                                rwall $host
                done

Whew.  I'd better stop before it gets too gross.

Adios,
  Logan
--
Logan Shaw, Unix System Administrator
"Everything is a struggle in Unix"  -Dave Keenan

 
 
 

How do I notify X users of system shutdown?

Post by Dan Merc » Fri, 04 Nov 1994 03:27:57



>I don't know how to notify these users of an impending system shutdown.  I
>can get their names out of the process table (not out of who), but I don't
>know the correct method for displaying a warning.

   1. Get lsof from a network site and compile it.  One of the options
      lists Internet ports.  Displays use port 6000,  so

          lsof -iTCP:6000

      will list all the X terminal connections

COMMAND     PID     USER   FD   TYPE       DEVICE   SIZE/OFF  INODE NAME
hpterm    13621      dam    3u  inet   0x032e0700    0x170bc    TCP medlab6.mmm.com:3259->medx7237.mmm.com:6000
vuelogin    407     root    3u  inet   0x03214480     0x6cd8    TCP medlab6.mmm.com:1173->medx7237.mmm.com:6000
xclock      519      dam    4u  inet   0x031d9000  0x17131d4    TCP medlab6.mmm.com:1212->medx7237.mmm.com:6000
nedit     13735      dam    7u  inet   0x03310e80    0x9751c    TCP medlab6.mmm.com:3370->medx7237.mmm.com:6000
X           757   daemon    3u  inet   0x0316c500        0x0    TCP *:6000
vuewm       465      dam    3u  inet   0x03212400   0xb37e4c    TCP medlab6.mmm.com:1199->medx7237.mmm.com:6000
vuewm       465      dam    4u  inet   0x031e9d80   0x108138    TCP medlab6.mmm.com:1209->medx7237.mmm.com:6000
xmtl       9309      dam    4u  inet   0x03203900    0x485d4    TCP medlab6.mmm.com:4721->medx7237.mmm.com:6000
xload       492      dam    4u  inet   0x031f0880   0x1ccf94    TCP medlab6.mmm.com:1211->medx7237.mmm.com:6000
vuesessio   452      dam    3u  inet   0x0331db80    0x1dd2c    TCP medlab6.mmm.com:1198->medx7237.mmm.com:6000
hpterm      637      dam    3u  inet   0x0330d180   0x4aa490    TCP medlab6.mmm.com:1327->medx7237.mmm.com:6000
hpterm    13552      dam    3u  inet   0x03304b80   0x1018ec    TCP medlab6.mmm.com:3099->medx7237.mmm.com:6000
hpterm     8135      dam    3u  inet   0x03212500   0x29b9e8    TCP medlab6.mmm.com:2521->medx7237.mmm.com:6000

   2. use [ng]awk to reformat the output  (we have an xusers script)

=============================== CUT HERE ===============================
#!/usr/local/bin/gawk -f
###############################################################################
# xusers            :  list xusers                                            #
# Created by        :  Dan Mercer                                             #
# Copyright         :  ClearSystems, Inc                                      #
# Date Created      :  Wed Nov  2 12:01:08 CST 1994                           #
# Date Last Altered :  Wed Nov  2 12:01:08 CST 1994                           #
###############################################################################
BEGIN {
ARGC = 1
cmd = "lsof -iTCP:6000"
"hostname" | getline hostname
while ((cmd | getline) > 0) {
    if (lnct++) {
        name = $NF
        if ("X" == $1) continue     # ignore X server entry
        sub ("^[^>]*>","",name)     # isolate X terminal portion
        split(name,t,"[:.]")
        name = t[1]
        T[name ":0.0"] = 1
        }
    }
for (i in T) print i

Quote:}

=============================== CUT HERE ===============================

   3. write a shell script to post an xterm with a warning message
      to their terminal.  Of course,  this will not work if they
      use Xauthority security.

--
Dan Mercer                                            ClearSystems, Inc

======================================================================
All opinions expressed are my own and do not reflect the opinions of
my employer or my employer's clients,  in particular 3M Company.
All advice or software offered or presented is provided As Is with no
warranty either expressed or implied.  Follow at your own risk.
Objects in the mirror are closer than they appear.

 
 
 

1. Q: How to notify DOS user they have mail on UNIX System

Hi all, I have 17 sites running UNIX (SCO and Solaris) servers.  Connected
are PCs with NFS and TCP/IP to these Servers.  Most apps are DOS/Windoze
including a mail package from TWG (Access Messenger Lite).  Each morning,
users turn on their PCs which access the server for the apps.  
Question:  During bootup, is there a way to check the server and each
users mailbox to see if there is any new mail and then print this on screen
before windoze starts?
I know when they log into the server directly, it prompts them that they
have new mail, but since they usually only log into the PCs, they don't have
this extra luxury.  
I know I can set up a crotab entry to check their mail each night or morning
and send a file to thier home dir but I'm unsure of the sequence.
Can anyone share some wisdom on this matter?

Thanks in advance,
        Donovan

2. "load: class javaclass not found" using Apache

3. Packages to notify users of system changes?

4. Motif 2.0 libs

5. System-shutdown without Super-User

6. tcsh - commandline editing does not go back to previous line!

7. Can a user do shutdown system?

8. Running more causes seg fault

9. Shutdown system as Non-root user

10. How do I allow a user to shutdown the system?

11. Needed - Remote user defn able to shutdown system

12. System Shutdown by user

13. Shutdown system by Joe User