Bruce Garlock came across this script and asked the authors for permission to republish it here:
Hm, how old this ditty is? I did not really touch Samba for a very loooong while. Does it still works with current versions? I even do not really remember how this script looks although I can roughly imagine.:-) I thought that at least in some moment this was included with some other third-party examples in Samba sources. I may mix that with some other two- or three-liner.
If you think that this is still useful then, sure, go ahead and publish it. It is already somewhere on the net. I hope that it is not too grotty. Likely faster to throw in something like that when you need it instead of trying to find it somewhere.
Michal
Bruce notes: FYI: I have tested this on SAMBA 2.2.7, RH AS 2.1
This is a perl script that sends out a SMB Message to all users via "WinPopUp", using SAMBA. I thought it would be a nice addition for the code section of the website. The authors and credits are part of the perl script.
#!/usr/bin/perl
#
#@(#) smb-wall.pl Description:
#@(#) A perl script which allows you to announce whatever you choose to
#@(#) every PC client currently connected to a Samba Server...
#@(#) ...using "smbclient -M" message to winpopup service.
#@(#) Default usage is to message every connected PC.
#@(#) Alternate usage is to message every pc on the argument list.
#@(#) Hacked up by Keith Farrar <farrar@parc.xerox.com>
#
# Cleanup and corrections by
# Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
# Message to send can be now also fed (quietly) from stdin; a pipe will do.
#=============================================================================
$smbstatus = "/usr/bin/smbstatus";
$smbshout = "/usr/bin/smbclient -d 3 -M";
if (@ARGV) {
@clients = @ARGV;
undef @ARGV;
}
else { # no clients specified explicitly
open(PCLIST, "$smbstatus |") || die "$smbstatus failed!.\n$!\n";
while(<PCLIST>) {
last if /^Locked files:/;
split(' ', $_, 6);
# do not accept this line if less then six fields
next unless $_[5];
# if you have A LOT of clients you may speed things up by
# checking pid - no need to look further if this pid was already
# seen; left as an exercise :-)
$client = $_[4];
print "\n",$client;
# next unless $client =~ /^\w+\./; # expect 'dot' in a client name
next if grep($_ eq $client, @clients); # we want this name once
push(@clients, $client);
}
close(PCLIST);
}
if (-t) {
print <<'EOT';
Enter message for Samba clients of this host
(terminated with single '.' or end of file):
EOT
while (<>) {
last if /^\.$/;
push(@message, $_);
}
}
else { # keep quiet and read message from stdin
@message = <>;
}
foreach(@clients) {
print "To $_:\n";
if (open(SENDMSG,"|$smbshout $_")) {
print SENDMSG @message;
close(SENDMSG);
}
else {
warn "Cannot notify $_ with $smbshout:\n$!\n";
}
}
exit 0;
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 5 | 7 | 21 | 1,132 | 7,923 |
/Unix/perlwinpopup.html copyright February 2004 Keith Farrar, Michal Jaegermann All Rights Reserved
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Publish your articles, comments, book reviews or opinions here!
---------------
I had use the smb-wall.pl script as base for other scripts. I would publish this scripts under the GPL-License. Now I'm looking for the author Keith Farrar to ask him for his "yes", that I can do this.
Please Keith Farrar look at my homepage www.tei-lin-net.de and contact me to say your meaning to my wish to publish the script "smb2lmhost", "smb-wall" and "smb-user-wall" under the GPL-License.
Heiko Teichmeier
-----------------
There exists a module on CPAN called Net::NetSend ( http://search.cpan.org/~greb/Net-NetSend-0.11/ ) which does send Windows popup messages directly. No Samba client is required to use this module.
(November 27, 2004)
Sun May 29 06:26:04 2005: Subject: Go ahead, it's already GPL anonymous
I contributed the script to the Samba team as a GPL Perl script.
-Keith <farrar@parc.xerox.com>
Add your comments