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
# Cleanup and corrections by
12
# Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
13
# Message to send can be now also fed (quietly) from stdin; a pipe will do.
14
#=============================================================================
16
$smbstatus = "/usr/local/bin/smbstatus";
17
$smbshout = "/usr/local/bin/smbclient -M";
23
else { # no clients specified explicitly
24
open(PCLIST, "$smbstatus |") || die "$smbstatus failed!.\n$!\n";
26
last if /^Locked files:/;
28
# do not accept this line if less then six fields
30
# if you have A LOT of clients you may speed things up by
31
# checking pid - no need to look further if this pid was already
32
# seen; left as an exercise :-)
34
next unless $client =~ /^\w+\./; # expect 'dot' in a client name
35
next if grep($_ eq $client, @clients); # we want this name once
36
push(@clients, $client);
44
Enter message for Samba clients of this host
45
(terminated with single '.' or end of file):
53
else { # keep quiet and read message from stdin
59
if (open(SENDMSG,"|$smbshout $_")) {
60
print SENDMSG @message;
64
warn "Cannot notify $_ with $smbshout:\n$!\n";