first post here, but was a lurker for ages. I searched for a long time, but I can’t find what I want (many obscure topics that do not ask what this topic offers ...). not new to awk or scripts, just a little rusty :)
I am trying to write an awk script that will set the values of the env shell at runtime - for another bash script to pick up and use later. I can't just use stdout from awk to report this value that I want to set (i.e., "export whatever = awk cmd here"), since it is already directed to the "result file" that awkscript creates (plus I have a few variables export in the final code).
As an example of a test script, to dismantle my problem:
echo $MYSCRIPT_RESULT
echo | awk -f scriptfile.awk
echo $MYSCRIPT_RESULT
inside scriptfile.awk, I tried (without success)
1 /) creating and executing an adhoc line directly:
{
cmdline="export MYSCRIPT_RESULT=1"
cmdline
}
2 /) using the system function:
{
cmdline="export MYSCRIPT_RESULT=1"
system(cmdline)
}
... but they do not work. I suspect that these two commands create a subshell in the awk shell that executes and does what I ask (verified by touching files as a test), but as soon as the cmd / system calls are complete, the subshell dies, unfortunately taking it, what I installed with it is therefore my env configuration changes do not stick to the awk caller viewpoint.
: env awk , env awk? ?
adhoc/system, , , ( "" -, script, imo ), , !
// !