如何将android的getevent输出重定向到文件? [英] How can I redirect android's getevent output to a file?

查看:204
本文介绍了如何将android的getevent输出重定向到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Android中的 getevent 命令重定向到设备上的文件。

I'm trying to redirect the getevent command in Android to a file on the device.

I尝试过的。 getevent> / path / to / file ,但这无效。当我 CTRL + C 时,文件为空。

I tried. getevent > /path/to/file, but that didn't work. When I CTRL+C'd, the file was empty.

经过进一步调查,我发现它可以正常工作如果我使用 getevent -c 标志,它告诉该过程在收到一定数量的事件后终止。这使我相信该问题与我正在终止该过程有关。当我使用 tee 而不是> 时,我看到直到该过程才会在stdout中显示输出

After further investigation, I discovered that it works if I use getevent's -c flag, which tells the process to terminate after a certain number of events are received. This leads me to believe that the problem is related to the fact that I'm killing the process. When I use tee instead of a >, I can see that the output does not show in stdout until the process finishes gracefully.

当然,问题在于 getevent 永远不会终止,我不能使用 -c 标志,因为我事先不知道会收到多少个事件。

The problem of course is that getevent never terminates, and I can't use the -c flag because I won't know beforehand how many events are going to be received.

如何重定向 getevent 以这样一种方式保存到文件中,即使在进程被杀死时也在那里?

How can I redirect the getevent to a file in such a way that it is there even when the process is killed?

如果

编辑:我通过进一步调查发现,如果我确保至少已发送25个事件,它将写入文件。但是,如果我确定已发送30个事件,则仅将这25个事件写入文件。

I've discovered through further investigation, that if I ensure that at least 25 events have been sent, it writes to the file. But if I ensure 30 events have been sent, only those 25 events will be written to the file. This confirmed my suspicion, that it's a buffer issue.

推荐答案

最后,我不得不编写一个调用logcat -c的脚本,这证实了我的怀疑。循环1个。

In the end, I had to write a script calling logcat -c 1 in a loop.

这篇关于如何将android的getevent输出重定向到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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