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
 
Manuel Collado  
View profile  
 More options Sep 15 2012, 2:52 pm
Newsgroups: comp.lang.awk
From: Manuel Collado <m.coll...@domain.invalid>
Date: Sat, 15 Sep 2012 20:52:14 +0200
Local: Sat, Sep 15 2012 2:52 pm
Subject: Re: windows scripting with gawk
El 15/09/2012 18:09, pop escribi :

> pop said the following on 9/15/2012 11:04 AM:
>> Manuel Collado said the following on 9/15/2012 9:56 AM:
>>>> There is no unix/linux equivalent method to set an environment
>>>> variable in
>>>> windows as explained above. The only way I have been able to do it
>>>> (within
>>>> [g]awk) is as follows:

>>>> set x=7
>>>> echo %x%
>>>> 7
>>>> gawk "BEGIN{ x=8;print \"@set x=\"x >\"setx.bat\" }"
>>>> call setx
>>>> echo %x%
>>>> 8

>>>> Note that "call" is used if in a batch file and further batch statements
>>>> are present since a batch file is immediately exited without the "call".

>>>> HTH
>>>> pop is Mark

>>> On Windows XP and later:

>>> awk "BEGIN {exit 8}"
>>> set x=%ERRORLEVEL%
>>> echo %x%
>>> 8

>> This only works for numerical values 0-255; other method will work for
>> all (legal) numerical values as well as text.

>> regards;
>> pop->Mark

> I stand corrected on the numerical values... apparently "exit number" works
> for any legal number...

If string values must also been supported, the there is a tricky solution
based on command expansions in FOR lists:

for /F %%k in ('awk "BEGIN {print \"alpha\"}"') do set x=%%k
echo %x%
alpha

The above works for a script in a file. At the interactive console just
type %k instead of %%k.

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado


 
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.