Hello,
I'm using gawk in widows batch to automate several processes.
Now I have an actual problem with passing batch parameters to gawk.
I stripped my problematic batch to a minimum to clarify my problem.
My minimalized batch is called "one.bat" with the following code:
[pre]
echo %1 | c:\Tools\awk\bin\awk.exe "{if ($1==\"test\") print (\"echo %2\") }" | cmd
[/pre]
The output of a programm (here simplified to echo %1) is processed by an awk one liner.
Awk generates an command line (here "echo %2") , which is executed by cmd.
This script works fine.
The problem rises, when %2 contains a DOS/Windows path to a file and contains backslashes.
E.g. when I pass the parameters "test" and "c:\path\tempfile" to my batch,
[pre]
one.bat test c:\path\tempfile
-->cath empfile[/pre]
the backslashes from %2 are interpreted as escape characters \p and \t,
which are removed from the ouput, \t is replaced by a TAB.
So I need to tell awg, that %2 is an ordinary string an no regular expressions.
Any ideas?
I'm using gawk in widows batch to automate several processes.
Now I have an actual problem with passing batch parameters to gawk.
I stripped my problematic batch to a minimum to clarify my problem.
My minimalized batch is called "one.bat" with the following code:
[pre]
echo %1 | c:\Tools\awk\bin\awk.exe "{if ($1==\"test\") print (\"echo %2\") }" | cmd
[/pre]
The output of a programm (here simplified to echo %1) is processed by an awk one liner.
Awk generates an command line (here "echo %2") , which is executed by cmd.
This script works fine.
The problem rises, when %2 contains a DOS/Windows path to a file and contains backslashes.
E.g. when I pass the parameters "test" and "c:\path\tempfile" to my batch,
[pre]
one.bat test c:\path\tempfile
-->cath empfile[/pre]
the backslashes from %2 are interpreted as escape characters \p and \t,
which are removed from the ouput, \t is replaced by a TAB.
So I need to tell awg, that %2 is an ordinary string an no regular expressions.
Any ideas?