如何从 root 设备中的 shell 脚本将 stdout 重定向到 logcat?

use*_*764 4 shell android stdout logcat

我在有根的 Android 设备中运行 shell 脚本,我试图通过跟踪 shell 脚本生成的 stdout 输出(通过命令或回显)来调试它。是否可以通过将 stdout 重定向到 logcat 来做到这一点?

小智 5

在您的 Android Shell 脚本中,使用以下内容:

   log -p v -t "test"  "test script message"
Run Code Online (Sandbox Code Playgroud)

然后,您将在 Androids Logcat 中看到您的消息:

adb logcat | 测试

用法:

log [-p priorityChar] [-t tag] message
    priorityChar should be one of:
        v,d,i,w,e
Run Code Online (Sandbox Code Playgroud)

这对我有用 Droid 4.4.3