我想从我的系统中检查DNS值
如果命令出错,错误应存储在不同的变量中
这就是我到目前为止所做的:
proc = subprocess.Popen(['echo', '"to stdout"'], stdout=subprocess.PIPE,)
stdout_value = proc.communicate()
print '\tstdout:', repr(stdout_value)
subprocess.call('echo #user', shell=True)
#subprocess.check_call('echo #HOME', shell=True)
你应该试试这个:
它从作为参数传递的命令中捕获errorcode、stdout和stderr: 导入shlex 从子流程导入Popen、PIPE
根据您的需要,我认为您可以使用python模块来获得所需的内容,而不是使用bash cmd行。例如,要获得完全限定的域名,您可以使用:
相关问题 更多 >
编程相关推荐