用管道扭曲运行本地shell命令 [英] twisted run local shell commands with pipeline

查看:78
本文介绍了用管道扭曲运行本地shell命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在扭曲的情况下,getProcessOutput方法可以通过使用 getProcessOutupt('ps','aux')来获取'ps'shell命令输出并返回延迟.

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

我的问题是如何在getProcessOutput中运行"ps aux | grep'某些关键字'| awk'{...}'"这样的命令.例如 getProcessOutput("ps aux | grep'某些关键字'| awk'{...}'").

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 '{...}'").

任何建议将不胜感激.

推荐答案

使用getProcessOutput('/bin/sh', ('-c', cmd)). cmd是您的shell命令.试试吧:-)

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

这篇关于用管道扭曲运行本地shell命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆