Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: samba winpopup script



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?



Messages sorted by: Reverse Date, Date, Thread, Author