python使用管道获取其它进程的输出内容

来源:互联网 发布:mac qq游戏大厅 编辑:程序博客网 时间:2024/05/18 18:44
  1. def GetLineListFromFile(sFileName):  
  2.     sCmd = "grep -i 'iphone os' " + sFileName;  
  3.     output = subprocess.Popen([sCmd],stdout=subprocess.PIPE,shell=True).communicate()  
  4.     lines = output[0].split('\n');  
  5.     return lines;  
  6.     #print (res)  
  7.       
  8. def GetLineListFromArch(sFileName):  
  9.     sCmd = "zgrep -i 'iphone os' " + sFileName;  
  10.     output = subprocess.Popen([sCmd],stdout=subprocess.PIPE,shell=True).communicate()  
  11.     lines = output[0].split('\n');  
  12.     return lines;