Serious_Developer <
ehabaz...@gmail.com> wrote:
> I must recall that thread because I did not find other group who could
> be asked. Sorry for that inconvenience but I have to ask this again
> for the urgent need .
> I am calling that batch file that I want to return to it a value from
> gawk script but it is not effective ????
> ENVIRON["codeinsidebat"]=codeawk
<snip>
Ignoring the Windows/batch stuff it sounds like you're trying to change
the value of an environment variable by changing it's value in the
ENVIRON[] array within awk. You simply can't do that. ENVIRON contains a
COPY of the environment variables names and associated values when awk
starts up, that's all.
Look (in UNIX, no idea what the Windows equivalent is):
$ x=7; awk 'BEGIN{ ENVIRON["x"]=8; print ENVIRON["x"] }'; echo "$x"
8
7
If you want to change the value of a variable in your environment as a
result of executing an awk script then you need to have awk return that
value and populate your variable from it, e.g.
$ x=7; x=$(awk 'BEGIN{ ENVIRON["x"]=8; print ENVIRON["x"] }'); echo "$x"
8
or generate a script to set the value and execute that script, e.g. with
UNIX eval:
$ x=7; eval $(awk 'BEGIN{ ENVIRON["x"]=8; print "x="ENVIRON["x"] }'); echo
"$x"
8
Regards,
Ed.
Posted using
www.webuse.net