[英]Is something like this possible in Python?
I have an executable file (hello.exe) that was given to me by a friend. 我有一个朋友给我的可执行文件(hello.exe)。 This executable file creates another exe file (test.exe) and runs the executable through another command line window.
该可执行文件创建另一个exe文件(test.exe),并通过另一个命令行窗口运行该可执行文件。 I wanted to was attempting to write a script that ran hello.exe, and grabbed the output of test.exe.
我想尝试编写运行hello.exe的脚本,并获取test.exe的输出。 I'm very new to python and am familiar with system calls and redirecting output, but this is a special case because I am not directly accessing test.exe.
我是python的新手,熟悉系统调用和重定向输出,但这是一种特殊情况,因为我没有直接访问test.exe。 Another problem I am facing is that hello.exe waits for a keyboard response from test.exe before doing anything else.
我面临的另一个问题是hello.exe在执行其他操作之前会等待来自test.exe的键盘响应。 Is it possible for me to run my hello.exe script and grab the output from test.exe in the same script?
是否可以运行hello.exe脚本并在同一脚本中获取test.exe的输出?
import sys, string, os
os.system(hello.exe) > "test.txt" //Something like this?? Grab output from test.exe and put in test.txt
print "test" //this doesn't print until keystroke from terminal running test.exe
perhaps 也许
os.system("hello.exe > test.txt")
alternatively 或者
subprocess.Popen("hello.exe",stdout=open("test.txt","w")).communicate("\n")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.