SUMMARY: passw awk variable to shell script

From: Dave Markham <dave.markham_at_fjserv.net>
Date: Tue Oct 31 2006 - 11:07:29 EST
Thanks to all who responded.

I tried Johan Hartzenberg who suggested :-

    echo $line | awk -F- ' ...... {print $1, $2}' | read BasePatch Rev

but this seemed to bum my script out with a test parameter somewhere.

Other people suggested just setting the vairable in shell e.g
 
    DEBUG=`grep "^Debug" ${CONF} | awk '{ print $2 }'`;  (thanks chris
hoogendyk)

but this was what i was trying to avoid as id need 2 lines.

The solution which seems to have worked and makes sense now is that awk
system commands will be acting as a sub process. The eval using
backticks has worked a charm :-


Heres code snippit :-

## Works but messy
#BasePatch=`echo $line |awk -F- '{print $1}'`
#Rev=`echo $line | awk -F- '{print $2}'`
## Below dont work. Trying to get rid of above 2 with 1
#####echo $line | awk -F- '{ system( "BasePatch=" $1 ) ; system( "Rev="
$2 )}'
## Below nearly works and perhaps should but isnt.
#####echo $line | awk -F- '{print $1,$2}' | read BasePatch Rev
## Below wins !
eval `echo $line | awk -F- '{ print "BasePatch=" $1 "; Rev=" $2 }'`


Thanks to all
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Oct 31 11:08:29 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:02 EST