试图从应用程序或代码中获取 tcpdump.我使用以下代码
try {
Process process = Runtime.getRuntime().exec(
"su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("/data/local/tcpdump-arm -c 10 -s 0 -w /data/local/out.txtn");
os.writeBytes("exitn");
os.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但得到异常java.io.IOException:写失败:EPIPE(Broken pipe)在os.writeBytes("/data/local/tcpdump-arm -c 10 -s 0 -w/data/local/out.txt");。请帮忙..
EPIPE 问题通常发生在您尝试在没有它的设备上执行需要根权限的命令 (getRuntime().exec) 或同时运行多个根命令时。