问题
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