By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TC12 Win7 console, running gawk scripts

I can't seem to run gawk or mawk scripts from the command line in a TC12 console window under Win7. I have defined gawk as an alias pointing to gawk.exe. To eliminate any problems w/ finding files or directories, I put my test script, test.awk, and the test data, xyz.txt, in the

c:\Program Files (x86)\GnuWin32\bin

directory, and ran my tests from this dir. My awk scritp looks like:

{ x++ }
{ print NF }

print "x =", x > "CON"

The infile xyz.txt contains 21 lines of plain text, each of between 0 and 5 words. I gave the command line string:

gawk -f test.awk xyz.txt > test.out

And this produces the result:

cannot open file `-f' for reading (No such file or directory)

Same result using -F option. If I leave the option flag out altogether no error message is generated and test.out is created, but it's empty.

I find the following strange.

1) If I do the same thing (including either -f or -F option flag) from a Win7 cmd console window, the outfile test.out contains the expected 21 lines each giving the correct number of fields for the corresponding infile lines and x=21 is echoed to the screen.

2) Same for mawk.

3) If I leave out the option flag in the cmd environment, gawk objects to test.awk in the command, but runs if the .awk suffix is omitted. But then the outfile is empty and there's no report to the screen.

4) Similar behavior with TC11 running XP Pro -- but Thompson Automation awk, tawk, runs fine with awk -f test.awk xyz.txt > test.out. Here awk is defined as an alias for the Thompson executable. Can't try this on Win7 because tawk is 16-bit.

If there's a way to run gawk or mawk scripts from a TC12 console in Win7, I'd very much like to know what it is. Maybe someone knows the reason for the differences between the cmd and TC12 behavior described above?

Thanks in advance.

Similar threads