Run Program> question

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
tbrahmer
Newbie
Posts: 15
Joined: Thu May 06, 2010 10:14 pm

Run Program> question

Post by tbrahmer » Tue Jul 20, 2010 7:05 pm

Having a problem with running a command line...
I use gawk all the time from a command prompt window - syntax is:
gawk.exe -f [script file] [input file] > [output file]
( the '>' is there to send the output to the output file and overwrite if it already exists, a '>>' can be sent to append - like batch files, etc.)

In a command prompt window:
when I type 'gawk.exe -f test.awk input.txt > output.txt' it works fine

However, in MS, when I use:
Run>gawk.exe -f test.awk input.txt > output.txt
it runs but the output is going to the command prompt window, not getting sent to the output.txt file via the '>'

Testing MS a little further:
Run>cmd.exe /c "gawk.exe -f test.awk input.txt > output.txt" works as it should and sends the output to output.txt

So it seems that the '>' or '>>' symbols are not working right when sent to the command prompt via the Run> command. I've tried compiling this as a 'console app' as well, but same result, it's like the '>' and everything after is getting ignored.

Does anyone know how to get my command line sent properly to the Run> command or am I stuck using the 'cmd.exe /c' method. I would prefer not to have to depend on cmd.exe because these gawk scripts will work on older machines which might have command.com instead.

Thanks for any help.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Jul 20, 2010 7:31 pm

Redirection is a function performed BY the command processor, so that is why it must be loaded first with the cmd /c (or command /c)

Now you can use the "ComSpec" environmental variable to determine which command processor is available on whatever machine you are running the script on.

Also see this post for my solution on how to read output
from command line programs directly
http://www.mjtnet.com/forum/viewtopic.p ... highlight=

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts