(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



WinPopup

By Keith Farrar, Michal Jaegermann

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;
 



More Articles by Keith Farrar, Michal Jaegermann




Click here to add your comments








http://www.allhyperlinks.com




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





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 which does send Windows popup messages directly. No Samba client is required to use this module.

(November 27, 2004)






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 which does send Windows popup messages directly. No Samba client is required to use this module.

(November 27, 2004)






---November 27, 2004



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 [http://search.cpan.org/~greb/Net-NetSend-0.10/|Net::NetSend ] which does send Windows popup messages directly. No Samba client is required to use this module.

(November 27, 2004)






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.10/) which does send Windows popup messages directly. No Samba client is required to use this module.

(November 27, 2004)



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>


Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



/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.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server






More:
       - Programming
       - Code
       - Perl
       - Microsoft


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress