From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14231 invoked from network); 4 Apr 2001 08:09:09 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Apr 2001 08:09:09 -0000 Received: (qmail 11565 invoked by alias); 4 Apr 2001 08:08:51 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3793 Received: (qmail 11553 invoked from network); 4 Apr 2001 08:08:50 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer goliath.siemens.de) From: "Andrej Borsenkow" To: "Louis-David Mitterrand" , Subject: RE: samba winpopup script Date: Wed, 4 Apr 2001 12:08:47 +0400 Message-ID: <000601c0bcde$79d8d930$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <20010404095255.A6819@apartia.ch> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 > > 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