Unblocking adb logcat in batch file - android

i want to have batch file for adb logging , my batch file goes like this
adb root
adb remount
adb shell cd /data/log/
adb shell logcat –v time >log_0.txt
adb shell logcat –v time –b radio >log_radio_0.txt &
adb pull /data/log/
the first logcat is blocking .. so the next logcat does not execute..
Please suggest how to unblock logcat here.
thanks in advance

Try this...
adb shell logcat -d -v time >log_0.txt

Related

nohangup using ADB shell

I am trying to do a logcat to a file using adb shell by following command -
adb shell "nohup logcat -f /storage/sdcard0/myLog.txt -v time &"
If I do a ps | grep logcat, I don't see the logcat command. Even I tried to see nohup command, but it is not there. So somehow above command does not work.
However if I perform the command in 2 steps it works fine -
adb shell
nohup logcat -f /storage/sdcard0/myLog.txt -v time &
I can see the process using ps and logcat continues to record to the file even if I disconnect adb shell. Now I would like the first command to work, since I am using python scripts to issue commands via ADB. It is possible to change the python scripts, however I would like to know if I am doing anything wrong in issuing the first command and if it is possible to make it work.
try
adb logcat
not
adb shell logcat

Making an ADB batch [ADB shell stopping issue]

This is my idea of what I want to do, simply execute the following commands but instead right after the line "adb shell" it stops, no other command can be triggered, whatever it is.
adb connect 192.168.1.101:5555
adb shell
su
rm /data/system/locksettings.db
rm /data/system/locksettings.db-wal
rm /data/system/locksettings.db-shm
PAUSE
reboot
adb shell command alone with out any extra parameters starts the shell in the interactive mode. Meaning it just sits there waiting for user input indefinitely. Your script never gets past that line.
What you really want is:
adb connect 192.168.1.101:5555
adb shell su 0 rm /data/system/locksettings.db
adb shell su 0 rm /data/system/locksettings.db-wal
adb shell su 0 rm /data/system/locksettings.db-shm
PAUSE
adb reboot

Running ADB commands through powershell

so I'm trying to run some ADB commands through a powershell script.
This is a simple example of what I am trying to do:
adb shell "
echo "in adb shell"
su root
echo "you are now root."
ls
cd /data/data
echo "in /data/data"
ls
"
I saw in a previous post to add the "" next to shell and at the bottom but that still didn't work for me. I can start the shell and the first ls works. but it just prints the rest of the commands out instead of doing them. The output I am getting looks like:
PS C:\Scripts> & .\test.ps1
: not found/sh:
in adb shell
su root
echo you are now root.
ls
cd /data/data
echo in /data/data
MSM8960_lpm.rc
acct
cache
.
.
.
ueventd.qcom.rc
ueventd.rc
vendor PS C:\Scripts>
Any help would be greatly appreciated. Thanks in advance!
Note: the path to ADB is within the powershell $env:path so the adb commands are working
I was able to get around this by doing:
adb shell "su -c '[cmd]; [cmd]' "

Running multiple adb commands with python Popen or os.system

One problem with ADB is that you need multiple commands to get things done.
For example:
adb shell
su
cp /data/local/x /data/local/y
exit
adb pull /data/local/y
Can this be done using python popen and os-system? Tried the example below without success..
print 'Starting emulator...'
subprocess.Popen(['emulator', '-avd', 'testavd'])
os.system('adb wait-for-device')
os.system('Perform whatever adb commands you need')
Any pointers?
You can simply do:
adb shell su -c cp /data/local/x /data/local/y
adb pull /data/local/y
or, if you want to run more than one command (only Linux & OSX):
adb shell <<EOF
ls
date
cat /proc/version
exit
EOF

How can I erase the old data from logcat?

When I execute the command
adb logcat
while running the android emulator, all of the old logs blow past and so I figure they are stored in a file somewhere. Is there a command I can run to clear the logs and start fresh? If not, is there some other way to do this?
Have you tried this?
adb logcat -c
https://developer.android.com/studio/command-line/logcat.html
adb logcat -c
didn't do it for me
adb logcat -b all -c
worked
Dup of
How to empty (clear) the logcat buffer in Android
The following command will clear only non-rooted buffers (main, system ..etc).
adb logcat -c
If you want to clear all the buffers (like radio, kernel..etc), Please use the following commands
adb logcat -b all -c
or
adb root
adb shell logcat -b all -c
For me, adb logcat -c was not working and was giving following error :
failed to clear the 'main' log
For this, I first did :
adb shell
Than I did :
logcat -c
then exit the shell.
This way I was able to clear logcat when same was not getting cleared from adb logcat -c

Categories

Resources