这个问题的摘要是,我有一个命令,我正在批处理, some.exe args
,但它没有输出到控制台。但是,如果使用 some.exe args> test.txt
。我尝试了@some.exe args
和 some.exe args&gt> con
将其输出到控制台,但似乎都没有起作用。
还有其他方法可能有效吗?
这就是从上一个问题中提出的,我问门使互动式窗口成为互动窗口。
我正在通过批处理脚本调用名为门的程序。它运行一个简单的脚本, hello.dxl
看起来像
cout << "Hello world"
批处理脚本, run.bat
看起来像
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl
运行时,屏幕上没有输出,没有输出弹出窗口或其他任何内容(如果 hello.dxl
说 print(“ Hello world”)
一个交互式窗口将弹出,但不要使用 cout
)
如果我添加&gt; test.txt
到命令的末尾,
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > test.txt
它成功地输出了 Hello World
test.txt
。我注意到的是,当使用 print(“ Hello world”)
没有发送到 test.txt
文件和一个交互式窗口,因此它看起来像 cout
是必经之路。
因此,尽管我可能只是在任何地方都不会输出输出,因此我尝试添加&gt; con
试图强迫它进入控制台。
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > CON
但这仍然导致空白输出。
我还尝试在命令之前添加@
,如此 batch -redirect program输出到当前console console ,喜欢
@"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl
或
@"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > CON
没有运气,
我本来想在没有门的情况下重现这个问题,但我不知道是什么首先造成了它。
编辑:我并不是真的想使用&gt; test.txt&amp;键入test.txt
这是我正在使用的当前解决方法。但理想情况下,我不希望它输出到文本文件
The summary of this question is I have a command I'm running in batch, Some.exe args
but it is not outputting to the console. It does however output to a text file if used like Some.exe args > test.txt
. I've tried stuff like @Some.exe args
and Some.exe args > CON
to get it to output to the console, but neither seems to work.
Are there any other approaches which might work?
This follows on from a previous question I asked DOORS make console the interactive window.
I'm calling a program called DOORS through a batch script. It runs a simple script, hello.dxl
that looks like
cout << "Hello world"
The batch script, Run.bat
looks like
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl
When this is run, no output appears on the screen and there are no popup windows or anything (if hello.dxl
said print("Hello World")
an interactive window would pop-up, but not with cout
)
If I add > test.txt
to the end of the command
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > test.txt
It outputs the Hello World
to test.txt
successfully. Something I noticed is when using print("Hello World")
there was no output sent to the test.txt
file and an interactive window popped up so it looks like cout
is the way to go.
So I though the output might just not be being output anywhere, so I tried adding > CON
instead to try to force it to go to the console.
"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > CON
But that still resulted in a blank output.
I also tried adding an @
, before the command, as suggested in this Batch - redirect program output to current console, like
@"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl
or
@"C:\Program Files\IBM\Rational\DOORS\9.6\bin\doors.exe" -u test -pass testPass -b hello.dxl > CON
But no luck there either
I would have tried to reproduce this issue without DOORS but I don't know what is causing it in the first place.
Edit: I'm not really looking to use > test.txt & type test.txt
as that is the current workaround I am using. But ideally I don't want it outputting to a text file
发布评论
评论(2)
事实证明,这种方法的功能有限,一旦我尝试打开一个模块,它就会使交互式窗口弹出,并且在交互式窗口或“控制台”窗口中看不到输出,
这不是
&gt; test.txt&amp;键入test.txt
基于@pa。但是,如果它是重定向的,所以我编写了一个小C#控制台应用程序,它看起来像
我然后使用命令将其导出到一个EXE中,
然后我添加了该命令,然后将其添加到我的路径环境变量中。
现在我可以做
,我得到了所需的输出
Turns out this approach has limited functionality, as soon as I tried opening a module, it made the interactive window pop up and no output was visible in the interactive window or the the console window
This is not an issue with the
> test.txt & type test.txt
workaroundBased on @PA.'s suggestion that the program is somehow preventing output to stdout but not if it was redirected, so I wrote a small C# console app which looks like
I then exported this to a single exe using the command
which I added then just added the folder with that exe in to my path environment variable.
Now I can just do
and I get the desired output
这更多是解决方法。
这个想法是使用管道程序,以将Windows程序的输出重定向到控制台:
作为管道程序,您可以使用通过所有内容传递所有内容的程序,例如:
是否有效取决于Windows程序。
关于时间:
当您长时间运行Windows程序时,可能会出现一些麻烦,该程序会产生零星的输出,或者始终完成输出始终到同一行(无线供稿,只有托架返回),并且您想实时实时输出。<<<<<<<<<<<<<<<<<<< br>
在这些cacses中,例如 findstr 或查找有点弱。
在github上,实现了 mtee ,这更合适:
This is more a workaround.
The idea is to a use a pipe program in order to redirect the output of the Windows program to the console:
As a pipe program you may use a program that passes throug everything, like:
If this works or not depends on the Windows program.
Concerning the timing:
There may be some trouble when you have a long time running Windows program which produces sporadic output or when the output is done always to the same line (no line feeds, only carriage returns) and you want to have the output in real time.
In these cacses Windows programs like findstr or find are a little bit weak.
On github there is an implementation of mtee thats fits better: