简体   繁体   中英

DOS Batch File Command does not execute

The following command line executes properly:

MagBoltz32 < input.txt > out.txt

The executable requires the input in brackets as above and outputs the text file. The following "batch.BAT" file (now including the escape characters) does NOT execute but simply hangs as if expecting more input.

MagBoltz32 ^< input.txt ^> out.txt
Executing batch.BAT simply results in a blinking cursor. Ultimately this command line will go into FOR loop which loops over several input/output files. I do have access to the source code.

That's not "input in brackets". The programm doesn't use any parameters (at least not in the shown syntax). It gets it's input from STDIN and writes to STDOUT.

<input.txt redirects the content of input.txt to STDIN, so the program is able to use it, like it were entered per keyboard.
>output.txt redirects STDOUT to the file output.txt instead of writing it to the screen.

Escaping characters is only needed, if you want the special char to be shown on the screen instead of "executing" it (simply spoken), so in your case, escaping the redirection characters makes no sense, but disables the redirection.

In some OS's you need to escape the pipes <, > and | so the syntax could be completely valid. This is particularly true for batch files ( http://www.robvanderwoude.com/redirection.php ) ... Have you checked to make sure all the files are in the same path that is executing the batch file? If you run the batch from C:\\foo even though bath.BAT is in c:\\bar, the input.txt will be expected to be in C:\\foo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM