>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