简体   繁体   English

DOS批处理文件命令不执行

[英]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. 下面的“ batch.BAT”文件(现在包括转义符)不会执行,而只是挂起,好像在等待更多输入一样。

MagBoltz32 ^< input.txt ^> out.txt
Executing batch.BAT simply results in a blinking cursor. 执行batch.BAT只会导致光标闪烁。 Ultimately this command line will go into FOR loop which loops over several input/output files. 最终,此命令行将进入FOR循环,该循环循环多个输入/输出文件。 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. 它从STDIN获取输入并将其写入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. <input.txt重定向的内容input.txt ,以标准输入,所以程序能够使用它,喜欢它是每个键盘输入。
>output.txt redirects STDOUT to the file output.txt instead of writing it to the screen. >output.txt将STDOUT重定向到文件output.txt而不是将其写入屏幕。

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? 对于批处理文件( http://www.robvanderwoude.com/redirection.php )尤其如此。...您是否已检查以确保所有文件都与执行批处理文件的路径相同? 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. 如果即使bath.BAT在c:\\ bar中,也从C:\\ foo运行批处理,则input.txt预计将在C:\\ foo中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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