I have success running a program I wrote (with file extension .exe) from the Windows command line with either an integer parameter or a redirection to specify input from a .txt file. Is there any way to do both?
For instance, the same project in Linux accepts './a.out 1 < testfile.txt' so 1 is in the arg array and testfile.txt is redirected as input. The same input in Windows will not work. I have tried something like ./a.exe (1 & '< testfile.txt') with no luck.
Thank you for any and all helpful responses, Tyler
2 Answers 2
This won't work:
a.exe 1< testfile.txt
because 1< is interpreted as "redirect standard handle #1". For most applications, this will work:
a.exe 1 < testfile.txt
(note the extra space!)
If your particular application chokes on the extra space, and for some reason you can't fix that, this is another option:
<testfile.txt a.exe 1
12 Comments
Try combining type command and pipe.
something like:
type testfile.txt | a.exe 11
You might have to tweek that. Can't test it here on linux :]
3 Comments
cmd.exe rather than your executable.Explore related questions
See similar questions with these tags.
a.exe 1 <testfile.txtshould work just fine. In what way, exactly, does it fail for you?