John Summerfied writes:
>Eddie Chen wrote:
>> I am trying to export a varable from awk and is not taken an effect when I
>> do "env" once I exit from the awk program.
>>
>> system(export ISODATE=`date --iso-8601`) or I think I also try "export
>> ISODATE=`date --iso-8601` | getline isodate "
>>
>> how do I set ENV varable in awk ...
>
>A program cannot change its parent's environment.
>
>A workaround is to write shell command(s) to a temp file then source it.
>
>In bash,
>help source
Or, if your awk script does not generate any output, you could have it
output the value and use this shell idiom to set an environment variable in
the parent:
export ISODATE=`awk '...system("date --iso-8601"); ...'`
It is not clear to me why you need to use awk to set the environment
variable. Is it possible to just have the parent shell script set it
before running awk? As in:
export ISODATE="`date --iso-8601`"
That makes the variable available to both your shell script and the awk
program.
Or is something in your awk script deciding to use the ISO 8601 date format
instead of some other date format? If so, consider refactoring your awk
script.
- MacK.
-----
Edmund R. MacKenty
Software Architect
Rocket Software, Inc.
Newton, MA USA
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390