Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用exec kubectl命令执行popen/子进程时出错_Python_Docker_Kubernetes_Kubectl_Popen - Fatal编程技术网

Python 使用exec kubectl命令执行popen/子进程时出错

Python 使用exec kubectl命令执行popen/子进程时出错,python,docker,kubernetes,kubectl,popen,Python,Docker,Kubernetes,Kubectl,Popen,我有以下python代码: command = "kubectl exec -it " + jmeter_pod + " -n " + namespace + " -- bash -c \"echo "+ ext_ip_lfe +">nelshost\" " process = subprocess.Popen(command.split(' '), stdout=subprocess.PI

我有以下python代码:

command = "kubectl exec -it " + jmeter_pod + " -n " + namespace + " -- bash -c \"echo "+ ext_ip_lfe +">nelshost\" "
process = subprocess.Popen(command.split(' '), stdout=subprocess.PIPE)
output = process.communicate()[0].decode('utf-8')
我有一段代码,当执行时,它在步骤“proces=…”返回此错误:


有人能帮我吗?

普通
split
不能将带引号的字符串放在一起
shlex.split()
does;但是为什么不自己把它分开呢

output=subprocess.run(
[“kubectl”,“exec”,“it”,jmeter_pod,
“-n”,命名空间“--”,
“bash”、“-c”、“echo”+ext\u ip\u lfe+“>nelshost\”],
text=True,check=True,
捕获\u输出=真)。标准输出
另请注意切换到
子流程。运行
;您应该尽可能避免
弹出

10.117.142.201>nelshost": -c: line 0: unexpected EOF while looking for matching `"'
10.117.142.201>nelshost": -c: line 1: syntax error: unexpected end of file
command terminated with exit code 1