[英]Scripting in linux
Why java -version
gives empty string when executing in subprocess.Popen
.为什么
java -version
在subprocess.Popen
执行时会给出空字符串。 Is there any alternative to get the exact text given by java -version
command in Linux ?有没有其他方法可以在Linux 中获取
java -version
命令给出的确切文本?
version = ["java","-version"]
temp1 = subprocess.Popen(version, stdout=subprocess.PIPE)
ver = str(temp1.communicate())
print ver
I think you are getting some error so capture the stderr from the process.我认为您遇到了一些错误,因此请从流程中捕获 stderr。
version = ["java","-version"]
temp1=subprocess.Popen(version, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = temp1.communicate()
Then try to print the error.然后尝试打印错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.