[K12OSN] Broadcast message
Petre Scheie
petre at maltzen.net
Fri Oct 29 17:25:30 UTC 2004
How about this:
who -T|awk 'NF == 7 {print $7}'|sed 's/^(//'|sed 's/)$//'
Should give you a list of client workstations that have someone logged in.
Petre
David Trask wrote:
> Ok....this python script is put together from an earlier suggestion (in
> March) from Doanld Ellerich I think.....
> ###################################
>
> from os import system
> from sys import argv
>
> hosts = open('clients.txt').readlines()
>
> if len(argv) < 2:
> argv.append("This is a broadcast message. Just in case something
> unexpected happens, save your work.")
>
> for host in hosts:
> system("xmessage -display %s:0 -center %s &" %
> (host.strip(), argv[1]))
>
> #############################
>
> I called it amesg.py
>
> To execute it run
>
> python amesg.py "Your message here"
>
>
> You'll need to create a text file called clients.txt and enter the host
> names in it
>
> example:
>
> ws224
> ws345
> ws123
>
> ++++++++++++++++
>
> Now for my issue....I have a host file with MANY entries due to the fact
> that my DHCP server is serving a huge range of addresses that I have
> seperated out for different things...anyway....my idea....how can we poll
> the server for the currently logged in workstations and then "cat" the
> result to "clients.txt" prior to broadcast? Any ideas? If you can write
> it into the script above or into the one Petre wrote earlier today.
>
> "Support list for opensource software in schools." <k12osn at redhat.com> on
> Friday, October 29, 2004 at 11:21 AM +0000 wrote:
>
>>I, too, was playing with xmessage, on Luis's suggestion, and came up with
>>this
>>quick & dirty script (which I'll call brmsg for discussion purposes):
>>
>>#!/bin/bash
>>
>># brmsg: Send a broadcast message to all terminal screens
>>
>>
>>for x in `seq 1 30`
>>do
>>xmessage -center -timeout 10 -display 192.168.0.${x}:0.0 "$@" &
>>done
>>
>>
>>One would then call brmsg this way at a command prompt from the server:
>>
>>brmsg Please logout now or you may be expelled
>>
>>The message will pop up on the client for 10 seconds and then disappear.
>>It
>>needs some refinement: For the seq range, it would be better to get a
>>list of
>>clients where someone is actually logged in so it doesn't waste time
>>sending
>>messages to irrelevant workstations; using 'who -T' and piping it to awk
>>would
>>be one way to get such a list. And, as David suggested, and graphical
>>version
>>of this would be nicer; perhaps I'll try something in perl/tk this
>>weekend (no
>>gaurantees, I've got a ton of leaves to rake).
>>
>>One requirement is that the client workstation must be configured to
>>accept such
>>messages, which in my server-and-one-client K12LSTP ver 3.0.1 here in my
>>cube,
>>the clients are not. This can be fixed by adding
>>
>>xhost +192.168.0.254
>>
>>to every user's ~/.profile. This will allow such messages to be sent
>
>>from the
>
>>server, but not from other clients which could be a nightmare, e.g.
>>clever
>>students with too much time on their hands.
>>
>>Hopefully this is a start.
>
>
>
>
> David N. Trask
> Technology Teacher/Coordinator
> Vassalboro Community School
> dtrask at vcs.u52.k12.me.us
> (207)923-3100
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
>
More information about the K12OSN
mailing list