diff options
author | Samba Release Account <samba-bugs@samba.org> | 1996-05-04 07:50:46 +0000 |
---|---|---|
committer | Samba Release Account <samba-bugs@samba.org> | 1996-05-04 07:50:46 +0000 |
commit | 0e8fd3398771da2f016d72830179507f3edda51b (patch) | |
tree | b5d07075a85050832720033f7b26c37a301ede72 /examples/misc/wall.perl | |
download | samba-0e8fd3398771da2f016d72830179507f3edda51b.tar.gz |
Initial version imported to CVS
(This used to be commit 291551d80711daab7b7581720bcd9a08d6096517)
Diffstat (limited to 'examples/misc/wall.perl')
-rw-r--r-- | examples/misc/wall.perl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/misc/wall.perl b/examples/misc/wall.perl new file mode 100644 index 00000000000..fc3dc2e2c05 --- /dev/null +++ b/examples/misc/wall.perl @@ -0,0 +1,45 @@ +#!/usr/local/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> +# +#============================================================================= +$smbstatus = "/usr/local/bin/smbstatus"; +$smbclient = "/usr/local/bin/smbclient"; + +print STDOUT "\nEnter message for Samba clients of this host\n"; +print STDOUT "(terminated with single '.' or end of file):\n"; + +while ( <STDIN> ) { + /^\.$/ && last; + push(@message, $_); +} + +if ( $ARGV[0] ne "" ) { + $debug && print STDOUT "Was given args: \n\t @ARGV\n"; + foreach $client ( @ARGV ) { + $pcclient{$client} = $client; + } +} else { + open( PCLIST, "$smbstatus | /bin/awk '/^[a-z]/ {print $5}' | /bin/sort | /bin/uniq|"); + while ( <PCLIST> ) { + /^[a-z]+[a-z0-9A-Z-_]+.+/ || next; + ($share, $user, $group, $pid, $client, @junk) = split; + $pcclient{$client} = $client; + } + close(PCLIST); +} + +foreach $pc ( keys(%pcclient) ) { + print STDOUT "Sending message "; + $debug && print STDOUT " <@message> \n"; + print STDOUT "To <$pc>\n"; + open(SENDMSG,"|$smbclient -M $pc") || next; + print SENDMSG @message; + close(SENDMSG); +} |