如何在Android进程运行时命令中使管道符号或Grep工作?

时间:2016-11-30 06:26:17

标签: android linux bash pipe runtime

我正在尝试执行以下命令;

theano-cache clear

日志结果为String cmd = "/system/bin/netstat -"+firstString+" | grep http"; Process process = Runtime.getRuntime().exec(cmd); Log.d("1:CMD VALUE", cmd);

然而,输出过滤了' http'参数。常规" / system / bin / netstat -a"结果是我得到的" / system / bin / netstat -a | grep http`"命令也是。为什么是这样?这是因为管道符号还是grep命令? 请帮忙。 感谢。

1 个答案:

答案 0 :(得分:0)

本网站的其他答案不是很清楚。这是解决方案。 您需要在运行时命令之前附加"/system/bin/sh -c"才能使grep正常工作。 干杯。

相关问题