* samba winpopup script
@ 2001-04-04 7:52 Louis-David Mitterrand
2001-04-04 8:08 ` Andrej Borsenkow
0 siblings, 1 reply; 3+ messages in thread
From: Louis-David Mitterrand @ 2001-04-04 7:52 UTC (permalink / raw)
To: zsh-users
Hello,
I am trying to build a script to notify all users on a LAN of network
conditions through the winpopup protocol. To get all users connected to
the samba server from which the winpopup messages will be sent I must
parse smbstatus' output:
Premier nobody nogroup 20067 sophia08 (192.168.5.100) Mon Apr 2 17:34:43 2001
Premier nobody nogroup 20079 dev03 (192.168.0.136) Mon Apr 2 17:39:33 2001
Premier nobody nogroup 20124 info09 (192.168.0.221) Mon Apr 2 18:00:01 2001
Premier nobody nogroup 7827 lnc_siege (192.168.0.70) Tue Mar 27 16:54:29 2001
[etc.]
And invoke:
% echo $MESSAGE | smbclient -M $MACHINE -I $IP
I started writing a script:
MESSAGE="test"
for i in `smbstatus | grep '(\w\+\.\w\+\.\w\+\.\w\+)' `; do
echo $i | read SHARE USER GROUP MACHINE IP JUNK
echo $MESSAGE | smbclient -M $MACHINE -I $IP
done
But $i contains each inidividual element of the smbstatus output, not
each line. How could I capture each line into $i and the read the
elements?
Thanks in advance for your help, cheers,
PS: I'd like the script to be compatible with /bin/sh ideally
--
"God is a mathematician of very high order, and he used very
advanced mathematics in constructing the universe." (Dirac)
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: samba winpopup script
2001-04-04 7:52 samba winpopup script Louis-David Mitterrand
@ 2001-04-04 8:08 ` Andrej Borsenkow
2001-04-04 18:01 ` Louis-David Mitterrand
0 siblings, 1 reply; 3+ messages in thread
From: Andrej Borsenkow @ 2001-04-04 8:08 UTC (permalink / raw)
To: Louis-David Mitterrand, zsh-users
>
> Hello,
>
> I am trying to build a script to notify all users on a LAN of network
> conditions through the winpopup protocol. To get all users connected to
> the samba server from which the winpopup messages will be sent I must
> parse smbstatus' output:
>
> Premier nobody nogroup 20067 sophia08
> (192.168.5.100) Mon Apr 2 17:34:43 2001
> Premier nobody nogroup 20079 dev03
> (192.168.0.136) Mon Apr 2 17:39:33 2001
> Premier nobody nogroup 20124 info09
> (192.168.0.221) Mon Apr 2 18:00:01 2001
> Premier nobody nogroup 7827 lnc_siege
> (192.168.0.70) Tue Mar 27 16:54:29 2001
> [etc.]
>
> And invoke:
>
> % echo $MESSAGE | smbclient -M $MACHINE -I $IP
>
> I started writing a script:
>
> MESSAGE="test"
> for i in `smbstatus | grep '(\w\+\.\w\+\.\w\+\.\w\+)' `; do
> echo $i | read SHARE USER GROUP MACHINE IP JUNK
> echo $MESSAGE | smbclient -M $MACHINE -I $IP
> done
>
> But $i contains each inidividual element of the smbstatus output, not
> each line. How could I capture each line into $i and the read the
> elements?
>
> Thanks in advance for your help, cheers,
>
> PS: I'd like the script to be compatible with /bin/sh ideally
>
Offhand - smbstatus definetely needs "no header" option like many others have.
smbstatus | grep '(\w\+\.\w\+\.\w\+\.\w\+)' | while read SHARE USER GROUP
MACHINE IP JUNK
do
... bla bla bla
done
-andrej
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: samba winpopup script
2001-04-04 8:08 ` Andrej Borsenkow
@ 2001-04-04 18:01 ` Louis-David Mitterrand
0 siblings, 0 replies; 3+ messages in thread
From: Louis-David Mitterrand @ 2001-04-04 18:01 UTC (permalink / raw)
To: Andrej Borsenkow; +Cc: zsh-users
On Wed, Apr 04, 2001 at 12:08:47PM +0400, Andrej Borsenkow wrote:
> > I started writing a script:
> >
> > MESSAGE="test"
> > for i in `smbstatus | grep '(\w\+\.\w\+\.\w\+\.\w\+)' `; do
> > echo $i | read SHARE USER GROUP MACHINE IP JUNK
> > echo $MESSAGE | smbclient -M $MACHINE -I $IP
> > done
> >
> > But $i contains each inidividual element of the smbstatus output, not
> > each line. How could I capture each line into $i and the read the
> > elements?
> >
> > Thanks in advance for your help, cheers,
> >
> > PS: I'd like the script to be compatible with /bin/sh ideally
> >
>
> Offhand - smbstatus definetely needs "no header" option like many others have.
>
> smbstatus | grep '(\w\+\.\w\+\.\w\+\.\w\+)' | while read SHARE USER GROUP
> MACHINE IP JUNK
> do
> ... bla bla bla
> done
On further consideration the script needs to weed out duplicates (users
that are connected to several samba shares):
(grep '(\w\+\.\w\+\.\w\+\.\w\+)' < smb.status |\
while read SHARE USER GROUP PID MACHINE IP JUNK
do
IP=${IP%%\)}
IP=${IP##\(}
echo $IP $USER $MACHINE
done) | sort | uniq | \
while read IP USER MACHINE
do
echo $IP $USER $MACHINE
bla bla bla ...
done
--
Your mouse has moved. Windows must be restarted for the change
to take effect. Reboot now?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-04-05 7:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-04 7:52 samba winpopup script Louis-David Mitterrand
2001-04-04 8:08 ` Andrej Borsenkow
2001-04-04 18:01 ` Louis-David Mitterrand
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).