Message from discussion
store retunning value from awk script to system variable
Received: by 10.224.31.20 with SMTP id w20mr476873qac.2.1347487290883;
Wed, 12 Sep 2012 15:01:30 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.52.30.164 with SMTP id t4mr3178vdh.4.1347487289522; Wed, 12
Sep 2012 15:01:29 -0700 (PDT)
Path: da15ni3445qab.0!nntp.google.com!v8no2145652qap.0!postnews.google.com!gk4g2000vbb.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Wed, 12 Sep 2012 15:01:29 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: gk4g2000vbb.googlegroups.com; posting-host=41.130.150.68; posting-account=ME0BFQoAAACWhnO11L6U9pHQnRUh_5gX
NNTP-Posting-Host: 41.130.150.68
References: <8794347d-8387-4569-b941-ac94693ba620@z4g2000vby.googlegroups.com> <pan.2012.08.20.17.11.27@thedarkdesign.free.fr.INVALID>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1
(KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1,gzip(gfe)
Message-ID: <bc5a0295-a846-4e72-b139-f4174e736a77@gk4g2000vbb.googlegroups.com>
Subject: Re: store retunning value from awk script to system variable
From: Serious_Developer <ehabaziz2...@gmail.com>
Injection-Date: Wed, 12 Sep 2012 22:01:30 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Aug 20, 7:11=A0pm, Loki Harfagr <l...@thedarkdesign.free.fr.INVALID>
wrote:
> Sun, 19 Aug 2012 17:51:34 -0700, happytoday did cat=A0:
>
> > How can under batch file to store value for returning value from awk
> > program ?
>
> for a direct answer to your direct question use Ed.'s answer
> for an indirect answer to your hidden probable question I'd say
> first use a file then use source on it
>
> a little PoC goes a long way cause it's hot:
>
> your given env var:
> -------------
> $ export _BARF=3D888
> -------------
>
> the PoC script:
> -------------
> $ cat bhappy.sh
> #!/bin/bash
>
> ### =A0 =A0 call thrice an awk script that might have a try at
> ### =A0 =A0 incrementing an environment variable
> ### =A0 =A0 this is the given env variable to play with
> echo "Before anything goes: $_BARF"
> _BARF=3D999
> export _BARF
> echo "Right after first fighting: $_BARF"
> ###
> ### =A0 =A0 this is the simple mind awk to do just what to do
> ###
> cat<<EOF>bhappy.awk
> BEGIN{
> x=3DENVIRON["_BARF"]
> x+=3D101
> ENVIRON["_BARF"]=3Dx
> printf("\n\tin awk, x=3D%s, envB=3D%s.\n",x,ENVIRON["_BARF"])}
>
> EOF
> ###
> cat<<EOT>bhappy2.awk
> BEGIN{
> x=3DENVIRON["_BARF"]
> x+=3D101
> printf("export _BARF=3D%s\n",x) > =A0 =A0_fout_}
>
> EOT
> ###
> awk -f bhappy.awk
> ### =A0 =A0 wont work as is
> export _BARF
>
> awk -v _fout_=3D"/tmp/_barfmeup" -f bhappy2.awk
> . /tmp/_barfmeup
> ### =A0 =A0 might and magic
> awk -v _fout_=3D"/tmp/_barfmeup" -f bhappy2.awk
> . /tmp/_barfmeup
>
> ###
> ###
> ###
> echo "There was a showdown this place: $_BARF"
> -------------
>
> just counting cards:
> -------------
> =A0./bhappy.sh
> Before anything goes: 888
> Right after first fighting: 999
>
> =A0 =A0 =A0 =A0 in awk, x=3D1100, envB=3D1100.
> There was a showdown this place: 1201
> -------------
I must recall that thread again to notify that command is not working
from sindei a batch file :
:loop
set source=3D%dir%\%codeloop%
if /I %codeloop% GTR %MAX% goto :End
echo %source%
pause ""
pushd %source%
dir /b "%source%\TMP*.RPT" > %source%\dir.txt
@for /F "tokens=3D*" %%* in (%source%\dir.txt) do (
@%binaries%\gawk -f %scripts%\alexbank_distribute_branches.awk %source%
\%%* 2> %scripts%\alexbank_distribute_branches.fil
echo from inside batch %codeinsidebat%
pause ""
)
My alexbank_distribute_branches.awk does not produce the value to
codeinsidebat variable using that statement :
ENVIRON["codeinsidebat"]=3Dcodeawk