[Samba] How to send a domain wide message with smbclient?

Andrew Gaffney agaffney at skylineaero.com
Sun Dec 28 14:04:48 GMT 2003

Travis L. Bean wrote:
> Is there a way to send a message to all users currently logged into a 
> Samba domain controller?  The reason why I ask is that I have a Samba 
> 3.x.x primary/backup domain controller setup and as soon as the system 
> monitor detects that the primary domain controller is offline I would 
> like to execute a command to send a domain wide message telling all 
> domain users to save their work to the local machine, log off the pdc 
> and log back in to the bdc.  Is there a way to accomplish this with 
> smbclient or another open source software solution?

You can send a message with a command such as 'echo "Testing" | smbclient -M <machine>'. I 
don't know if there is a way to send a message to all clients. You could try to do it 
yourself. If you have any bash/sed/awk or perl abilities, you could write a script that 
parses the output of 'smbstatus' to determine which clients are currently logged on to the 
domain. It could then go through a loop and send the message to every client. In perl:


open PIPE, "smbstatus |";
foreach $line (<PIPE>) {
   if($line =~ /\d+\s+(\S+)\s+\S+\s+(\S+)\s+\((.+)\)/) {
     system "echo 'Attention user $1! PDC is down. Please save all work to local disk, 
logout, and log back in on the BDC.' | smbclient -M $2 -I $3";

I ran a brief test on this and it appears to work correctly with 3.0.1.

Andrew Gaffney

More information about the samba mailing list