python - Regarding about subprocess .Popen
问题描述
The output getting from the one subprocess that can be used in the middle of the another subprocess but the "NO OUTPUT" is getting for that subprocess. but that output value is getting printing at line of the code. But that value is not appending to the another subprocess. Code
import subprocess
import os
import sys
Name_cmd ="kubectl get pods"+" -n "+namespace_name
p2 = subprocess.Popen(Name_cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
output1, err=p2.communicate()
podname=output1.strip()
print(podname)
status="kubectl exec -it" + podname + "-n"+ namespace_name+"| grep run"
p6=subprocess.Popen(status,stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
output,error=p6.communicate()
print(output)
From the above Code where podname is not get taken by the second subprocess.Popen Where after executing the p6 nothing is displayed. If i give a particular value in the place of podname in the p6 it will gives my desired output.
解决方案
推荐阅读
- javascript - 为什么我的节点包管理器在安装它并运行 pacakage.JSON 文件后给我错误?
- javascript - 源地图未在 Google Chrome 中激活
- python - 彩色图像上卷积滤波器后输出张量的形状
- opencv - 如何检测连续图像
- ios - 如何在 Swift 中绘制视图之前从服务器加载数据
- python - 如何使用python将选定部分的坐标存储为列表?
- java - 在 Spring Data 中拦截存储库方法调用,动态优化查询
- amazon-web-services - AWS私有弹性ip
- css - 不使用 Bootstrap 4 flex 进行包装
- c - 如何修复不兼容的指向从“void *”分配给“int”的整数转换指针