Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion windows scripting with gawk
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ed Morton  
View profile  
 More options Sep 14 2012, 2:35 pm
Newsgroups: comp.lang.awk
From: "Ed Morton" <mortons...@gmail.com>
Date: Fri, 14 Sep 2012 18:35:49 GMT
Local: Fri, Sep 14 2012 2:35 pm
Subject: Re: windows scripting with gawk

Serious_Developer <ehabaziz2...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.