[Samba] ShowMessage (second attempt)
Martin Thomas
mthomas at rhrk.uni-kl.de
Wed May 21 18:09:21 GMT 2003
>From: "A.J.Dawson" <A.J.Dawson at Bradford.ac.uk>
>Subject: Re: [Samba] ShowMessage (second attempt)
>To: Nicholas Metsovon <nmetsovo at yahoo.com>
>Cc: samba at lists.samba.org
>I could also *really* do to use this feature now and again!
>
>Regards
>
>Dr. Andy Dawson
>A.J.Dawson at Bradford.ac.uk
>http://www.mossie.org
>http://www.museum-explorer.org.uk
>
> Never attribute to malice that which is adequately explained by stupidity.
>
>
>On Tue, 20 May 2003, Nicholas Metsovon wrote:
>
>> Surely someone out there knows how to notify their
>> Windows users that access to their samba server is
>> going to be terminated....
>>
>> Any help will be *greatly* appreciated.
>>
>> ------ Original Message -------
>> I would like to shut down samba before I begin my
>> backup routine. Before I do this, I would like to
>> send a message to the users who are logged in on their
>> Windows machines, asking them to log out. I would
>> prefer this to be like a ShowMessage dialog box, if
>> possible.
>>
>> Could anyone please tell me how I can do this? A
>> Redhat tech support specialist told me he thinks this
>> is possible through samba or smb-client.
I wrote the following script some time ago to message
all connected clients thru "smbclient -M" .
I did some comments and clean-up today and hope
this did not break anything. You should get the idea.
The windows-messageing service (don't know the
right translation in the german W2K it's called
"Nachrichtendienst") has to be active on the clients.
It's active by default in Windows 2000 and I think
in XP too.
Hope this helps
Martin
-------- cut
#!/bin/bash
# Header above the message
infoline="** Nachrichtendienst des xxxx-Netzes **"
# Name of Sender
sender="System/xxx"
# location of the executeables
smbstatusexe=`which smbstatus`
smbclientexe=`which smbclient`
# take the brief output from smbstatus, extract the 3rd column
# (the client name) and save all names in reverse order
clients=`$smbstatusexe -b|tr -s " " ";"|cut -d";" -f3|tac`
if [ $# -lt 1 ]
then
echo "Usage: $0 Message"
echo "Will send the message to all MS-Windows clients having an active"
echo "connection to this Samba-host. At the moment these are:"
for i in $clients
do
# test for last line (the "--------" line)
if [ `expr "$i" : '-*'` -ne 0 ]
then
break
fi
echo -n "$i "
done
echo " "
exit 2
fi
for i in $clients
do
if [ `expr "$i" : '-*'` -ne 0 ]
then
break
fi
echo -n "Sending Message to Host $i - "
# send the message, "number of bytes send" is grepped to show
# fail/success
echo -e "$infoline\n$*" | $smbclientexe -U $sender -M $i | grep sent
done
---
Dipl.-Ing. Martin THOMAS
University of Kaiserslautern, Institute of Environmental Engineering,
Kaiserslautern (D-67663), Germany
More information about the samba
mailing list