[mdk-re] Re: WinPopup из самбы всей группе

Sergei Makarov =?iso-8859-1?q?smakarov_=CE=C1_nes=2Eru?=
Вт Апр 23 11:41:01 MSD 2002


Посмотрите скрипт в аттаче.



Michael Shigorin wrote:
> On Mon, Apr 22, 2002 at 09:14:04AM +0400, Eugene Prokopiev wrote:
> 
>>Как из самбы отправить попап всей группе, а не отдельному компьютеру ?
> 
> (short answer) Кажется, никак.
> 
> (long answer) Можно попробовать наваять какой-то мессенджер,
> который сделает browse (как-то при помощи smbclient, думаю),
> потом распарсить вывод и раскидать в индивидуальном порядке :-(
> 
> Если сделаете -- бросайте сюда, думаю, хором доведем ;-)
> 

----------- следующая часть -----------
#!/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 -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];
	#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;



Подробная информация о списке рассылки community