From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27205 invoked from network); 5 Apr 2001 07:39:40 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Apr 2001 07:39:40 -0000 Received: (qmail 29891 invoked by alias); 5 Apr 2001 07:39:22 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3796 Received: (qmail 29880 invoked from network); 5 Apr 2001 07:39:21 -0000 Date: Wed, 4 Apr 2001 20:01:08 +0200 From: Louis-David Mitterrand To: Andrej Borsenkow Cc: zsh-users@sunsite.dk Subject: Re: samba winpopup script Message-ID: <20010404200108.A2996@apartia.ch> Mail-Followup-To: Andrej Borsenkow , zsh-users@sunsite.dk References: <20010404095255.A6819@apartia.ch> <000601c0bcde$79d8d930$21c9ca95@mow.siemens.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.17i In-Reply-To: <000601c0bcde$79d8d930$21c9ca95@mow.siemens.ru>; from Andrej.Borsenkow@mow.siemens.ru on Wed, Apr 04, 2001 at 12:08:47PM +0400 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?