twisted run local shell commands with pipeline

China☆狼群 提交于 2019-12-11 07:17:29

问题


In twisted, getProcessOutput method could get 'ps' shell command ouput by using getProcessOutupt('ps', 'aux') and return a defer.

my question is how to run command like "ps aux | grep 'some keyword' | awk '{...}'" in getProcessOutput. for example getProcessOutput("ps aux | grep 'some keyword' | awk '{...}'").

any suggestions would be appreciated.


回答1:


use getProcessOutput('/bin/sh', ('-c', cmd)). cmd is your shell command. try it :-)



来源:https://stackoverflow.com/questions/28957258/twisted-run-local-shell-commands-with-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!