我正在尝试在python中一个接一个地使用以下两个命令。在
runmqsc <Queuem manager name>
Display QL (<queue name>)
我可以使用子进程执行rumqsc命令。在
^{pr2}$现在这些命令似乎从python获得了控制权。如果我试图使用子进程执行下一个命令,它将无法按预期工作。 我甚至不知道如何执行第二个(我必须传递一个参数)。在
添加代码段:
subprocess.call("runmqsc Qmgrname", shell= True)
subprocess.call("DISPLAY QL(<quename>)",shell=True)
现在第一行执行得很好,正如tdelaney在runmqsc注释中所提到的,它等待来自stdin的输入。在执行第一行之后,程序甚至没有执行第二行就挂起了。在
任何帮助或对任何相关文档的引用都会有所帮助。 谢谢
您不希望按顺序运行到子进程命令。当您在命令行上运行
runmqsc
时,它接管stdin
,执行您输入的命令,然后在您告诉它时退出。来自the docs:但我认为还有第三种方法。启动} 是为你做的。我不知道你是否想捕捉输出,但在这个例子中,我让它进入屏幕。在
runmqsc
,将命令写入stdin
,然后关闭stdin
。它应该执行命令并退出。原来^{在python3中,
^{pr2}$out
和err
是bytes
对象,而不是字符串。与读取文本文件时使用编码类似,您可能必须根据程序使用的任何语言对其进行解码。假设文件是UTF8,那么你就可以了在Unix、Linux或Windows上,您只需执行以下操作:
在“some\u mq”里_命令.mqsc'文件,将MQSC命令放在如下位置:
^{pr2}$相关问题 更多 >
编程相关推荐