i'm trying send a command through adb to an android device in order to trigger logcat recording to a file on the device. to do so, i trigger the command:
adb shell "logcat > /sdcard/logcat.log"
so far so good, but the thing is that i need the command to run in the background, and not to keep an open connection to the PC. meaning, that if i send a command and disconnect the usb cable, i want to have the logcat recording keep running in the background. if i execute
$ adb shell
$ logcat > /sdcard/logcat.log &
I can safely disconnect the USB cable, and the recording will keep on going. however, if i execute the command from outside of the shell as follows:
adb shell "logcat > /sdcard/logcat.log &"
i get a file in /sdcard
called logcat.log
which weights 0 bytes.
after trying several varieations i tried placing a script file with the command
"logcat > /sdcard/logcat.log &
" in /sdcard called /logcatScript.log
and running it from outside of the shell using
adb shell "sh /sdcard/logcatScript.log"
but the same 0 byte file is being created.
The device is not rooted, and should not be, so busyBox is not an option.
The best way to solve it is to create a bash script an push it into data/local/tmp folder, on most android devices there is no need to define the #!/system/bin/sh or #!/bin/bash in the first line. The procedure is:
1)Create file with : logcat > /sdcard/logcat.txt &
2)adb push /data/local/tmp
3)adb shell chmod +x /data/local/tmp/
4)adb shell /data/local/tmp/
Regards