启用控制台应用程序的输出到脚本
我有一个小型 C++ 控制台应用程序,它显示一个菜单,然后执行所选操作。
此外,我还编写了一个 VBScript,它在 StdOut(由 Exec 实现)上运行并将值输入到 StdIn。
但是,当我尝试执行此脚本时,控制台应用程序卡在 scanf 调用中,并且脚本没有从输出中接收任何内容。 _flushall() 没有帮助。
有人知道吗?
谢谢。
I have a small C++ console application which presents a menu then performs the chosen operation.
In addition, I've written a VBScript which runs over the StdOut (achieved by Exec) and enters to StdIn the values.
However when I'm trying to executet this script the console application is stuck in the scanf call and the script doesn't receive anything from the output. _flushall() doesn't help.
Does anyone have any idea?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对于 VBScript/Windows Scripting Host 来说非常困难,因为没有非阻塞 IO。换句话说,没有办法说“阅读现在可用的任何内容,然后立即返回”。
如果您确切地知道程序在每种情况下将创建什么输出,则可以从脚本中执行此操作。
在大多数情况下,如果可能的话,最好将程序设置为非交互式“批处理”模式,其中程序接受命令但不需要响应提示。
This is very difficult from VBScript/Windows Scripting Host, as there is no non-blocking IO. In other words, there is no way to say "Read whatever is available right now, then return immediately".
It is possible to do this from script, provided you know EXACTLY what output the program will create in every circumstance.
In most situations it is better to set the program up in a non-interactive "batch" mode if possible, where the program accepts commands but without any need to respond to prompts.