Thanks Rob, I saw that variable/array in the manual and yes I get the variable
passed
into awk. Works great.
Thanks much. Owe you one.
Jeff Fitzwater
Princeton University
Rob Macgregor wrote:
> It *is* possible to get environment variables inside awk. They are passed as
> an array
> "ENVIRON" with the index of the array being the name of the variable. So for
> example:
>
> $ export THING="thong"
> $ awk 'BEGIN {print ENVIRON["THING"]}'
> thong
>
> One thing to look out for -- on Solaris you have to use the "enhanced"
> version of awk
> (called nawk) for this function. As far as I remember, the AIX version works
> this way
> as standard.
>
> Rob Macgregor
>
> Jeff Fitzwater wrote:
>
> > Thanks much James. I knew what you meant on the first mail. I guess awk
> > can't
> > get variable passed directly to it. It must get passed to a shell then to
> > awk.
> > I can make it work now.
> >
> > thanks again.
> >
> > Jeff F.,
> >
> > James_Shanks@tivoli.com wrote:
> >
> > > Rats. I am too clumsy. That should read
> > > echo $NVA >> /myfile
> > > echo $NVATTR_1 >> /myfile
> > > .....
> > > echo $NVATTR_n >> /myfile
> > >
> > > so that you append to that file, other wise the only variable in it will
> > > be the
> > > last one.
> > >
> > > James Shanks
> > > Tivoli (NetView for UNIX and NT) L3 Support
> > >
> > > James_Shanks@TIVOLI.COM on 05/10/2000 04:31:08 PM
> > >
> > > Please respond to IBM NetView Discussion <nv-l@tkg.com>
> > >
> > > To: IBM NetView Discussion <nv-l@tkg.com>
> > > cc: (bcc: James Shanks/Tivoli Systems)
> > > Subject: Re: [NV-L] Passing NVA event Attribute to awk script ??
> > >
> > > I'm confused here. Sorry.
> > > In a ruleset action node $NVA will resolve to the agent address, which
> > > should
> > > resolve to a hostname.
> > > But to get attribute number one, you use $NVATTR_1 not $1 like you do for
> > > trapd.
> > >
> > > But I think your script is probably getting the variable correctly.
> > > To prove that I would add this to it right at the beginning:
> > > echo $NVA > /myfile
> > > echo $NVATTR_1 > /myfile
> > > .....
> > > echo $NVATTR_n > /myfile
> > >
> > > for however many you have and go look in myfile after it executes
> > >
> > > James Shanks
> > > Tivoli (NetView for UNIX and NT) L3 Support
> > >
> > > _________________________________________________________________________
> > >
> > > NV-L List information (unsubscribing, policies, posting, digest version,
> > > searchable archives): http://www.tkg.com/nv-l
> > >
> > > _________________________________________________________________________
> > >
> > > NV-L List information (unsubscribing, policies, posting, digest version,
> > > searchable archives): http://www.tkg.com/nv-l
>
> --
> Rob Macgregor.
> Systems Management and Network Security Consultant,
> Nervus Systems
> Mobile: +44 (0) 7714 215165
> Fax: +44(0) 1794 513434
>
> _________________________________________________________________________
>
> NV-L List information (unsubscribing, policies, posting, digest version,
> searchable archives): http://www.tkg.com/nv-l
jfitz.vcf
Description: Card for Jeff Fitzwater
|