On Thursday 07 February 2008 03:46:49 pm Red Mop wrote:
> On Thursday 07 February 2008 02:37:49 pm Richard Geoffrion wrote:
> > I don't know the proper question to ask, so I'm going to ask it in
> > several ways so that hopefully I can get my point across.
> >
> > Attempt1:
> > What is the best way for me to populate a BASH ARRAY with the paths of
> > all of the configured banks in /etc/dirvish/master.conf?
> >
> > Attempt2:
> > Is there a way to have the dirvish scripts list out all of the bank
> > paths (and just the bank paths) from the /etc/dirvish/master.conf file
> > so that I can use the paths in a shell script
> >
> > Attempt3:
> > Is there a 'dirvishy' way that one can make the paths located in the
> > bank: section of the /etc/dirvish/master.conf file available to shell
> > scripts?
> >
> > I've looked at the dirvish perl script and I have to say that it's a bit
> > more complicated than I feel comfortable tackling.
>
> If they are all prefixed with the same thing, it's simple enough...
>
> for X in `grep /home/dirvish /etc/dirvish/master.conf` ; do
> TEST="$X $TEST"
> done
>
> echo $TEST
>
> Else, it gets more complicated.
>
> _______________________________________________
> Dirvish mailing list
> [email protected]
> http://www.dirvish.org/mailman/listinfo/dirvish
This works too.
BANK_FOUND=0
BANK_ENDED=0
for X in `cat /etc/dirvish/master.conf` ; do
if [ `echo ${X} | grep -q -e : ; echo $?` == 0 ] ; then
if [ `echo ${X} | grep -q -e bank: ; echo $?` == 0 ] ; then
echo bank: found
BANK_FOUND=1
BANK_ENDED=0
else
echo bank ended
BANK_ENDED=1
fi
fi
echo $BANK_FOUND $BANK_ENDED
if [ $BANK_FOUND == 1 ] && [ $BANK_ENDED == 0 ] ; then
BANKS="$BANKS $X"
fi
done
echo $BANKS
_______________________________________________
Dirvish mailing list
[email protected]
http://www.dirvish.org/mailman/listinfo/dirvish