zsh-users
 help / color / mirror / code / Atom feed
From: Louis-David Mitterrand <vindex@apartia.ch>
To: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
Cc: zsh-users@sunsite.dk
Subject: Re: samba winpopup script
Date: Wed, 4 Apr 2001 20:01:08 +0200	[thread overview]
Message-ID: <20010404200108.A2996@apartia.ch> (raw)
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?


      reply	other threads:[~2001-04-05  7:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-04  7:52 Louis-David Mitterrand
2001-04-04  8:08 ` Andrej Borsenkow
2001-04-04 18:01   ` Louis-David Mitterrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010404200108.A2996@apartia.ch \
    --to=vindex@apartia.ch \
    --cc=Andrej.Borsenkow@mow.siemens.ru \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).