为什么 subprocess.Popen 不起作用
我尝试了很多事情,但由于某种原因我无法让事情发挥作用。我正在尝试使用 Python 脚本运行 MS VS 的 dumpbin 实用程序。
以下是我尝试过的(以及对我不起作用的)
1.2.3
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = '"C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin" /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = 'C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
kernel32.dll
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
process = subprocess.Popen(['C:\\Program Files\\Microsoft Visual Studio 8\\VC\\bin\\dumpbin', '/EXPORTS', dllFilePath], stdout = tempFile)
process.wait()
tempFile.close()
有人知道我正在尝试做的事情吗(dumpbin /EXPORTS C:\Windows\system32\ > tempfile.txt
) 在Python中正确吗?
I tried a lot of things but for some reason I could not get things working. I am trying to run dumpbin utility of MS VS using a Python script.
Here are what I tried (and what did not work for me)
1.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = '"C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin" /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
2.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
command = 'C:/Program Files/Microsoft Visual Studio 8/VC/bin/dumpbin /EXPORTS ' + dllFilePath
process = subprocess.Popen(command, stdout=tempFile)
process.wait()
tempFile.close()
3.
tempFile = open('C:\\Windows\\temp\\tempExports.txt', 'w')
process = subprocess.Popen(['C:\\Program Files\\Microsoft Visual Studio 8\\VC\\bin\\dumpbin', '/EXPORTS', dllFilePath], stdout = tempFile)
process.wait()
tempFile.close()
does anyone have any idea on doing what i am trying to do (dumpbin /EXPORTS C:\Windows\system32\kernel32.dll > tempfile.txt
) correctly in Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Popen 的参数模式需要一个用于非 shell 调用的字符串列表和一个用于 shell 调用的字符串。这很容易解决。给定:
使用
shell=True
调用 subprocess.Popen:或使用 shlex.split 创建参数列表:
The argument pattern for Popen expect a list of strings for non-shell calls and a string for shell calls. This is easy to fix. Given:
Either call subprocess.Popen with
shell=True
:or use shlex.split to create an argument list: