3 #@(#) smb-wall.pl Description:
4 #@(#) A perl script which allows you to announce whatever you choose to
5 #@(#) every PC client currently connected to a Samba Server...
6 #@(#) ...using "smbclient -M" message to winpopup service.
7 #@(#) Default usage is to message every connected PC.
8 #@(#) Alternate usage is to message every pc on the argument list.
9 #@(#) Hacked up by Keith Farrar <farrar@parc.xerox.com>
11 #=============================================================================
12 $smbstatus = "/usr/local/bin/smbstatus";
13 $smbclient = "/usr/local/bin/smbclient";
15 print STDOUT "\nEnter message for Samba clients of this host\n";
16 print STDOUT "(terminated with single '.' or end of file):\n";
23 if ( $ARGV[0] ne "" ) {
24 $debug && print STDOUT "Was given args: \n\t @ARGV\n";
25 foreach $client ( @ARGV ) {
26 $pcclient{$client} = $client;
29 open( PCLIST, "$smbstatus | /bin/awk '/^[a-z]/ {print $5}' | /bin/sort | /bin/uniq|");
31 /^[a-z]+[a-z0-9A-Z-_]+.+/ || next;
32 ($share, $user, $group, $pid, $client, @junk) = split;
33 $pcclient{$client} = $client;
38 foreach $pc ( keys(%pcclient) ) {
39 print STDOUT "Sending message ";
40 $debug && print STDOUT " <@message> \n";
41 print STDOUT "To <$pc>\n";
42 open(SENDMSG,"|$smbclient -M $pc") || next;
43 print SENDMSG @message;