I'm running a shell script in a rooted Android device, and I'm trying to debug it by tracing the stdout output generated by the shell script(either by the commands or by echo). Is it possible to do this by redirecting stdout to logcat?
Asked
Active
Viewed 4,419 times
4

Ciro Santilli OurBigBook.com
- 347,512
- 102
- 1,199
- 985

user1118764
- 9,255
- 18
- 61
- 113
-
If you can find the file that logcat is writing to, you can just use the command "command >> logcatfile" – Gabe Sechan Jun 27 '13 at 07:27
-
possible duplicate of [Why is redirecting stdout/stderr on android not working?](http://stackoverflow.com/questions/5499202/why-is-redirecting-stdout-stderr-on-android-not-working) – grattmandu03 May 07 '15 at 09:34
2 Answers
7
Within your Android Shell script, use the following:
log -p v -t "test" "test script message"
You will then see your message within Androids Logcat:
adb logcat | grep test
Usage:
log [-p priorityChar] [-t tag] message
priorityChar should be one of:
v,d,i,w,e
This works for me on Droid 4.4.3
0
You can redirect stdio to logcat. This works for me, so that NDK C code printfs appear in logcat. Redirect method