I can't get the logcat to clear out it worked when i had just one device running but when i have two it doesn't work. I'm running the script every 5 mins and want the log to be cleared so the log file created is for that particular test run each time.
logcat -c is the command to clear it but it doesn't seem to be working
any ideas?
cd C:\Users\nicho\android-sdks\platform-tools
adb
adb -s emulator-5554 shell logcat -c
adb -s emulator-5554 shell am instrument -w com.example.nicho.pleasework.test/android.test.InstrumentationTestRunner
set timestamp=%date:~-4,4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%%time:~6,2%
adb -s emulator-5554 logcat -d -v time MyTest:I > "C:\Users\nicho\Desktop\logs\robotium\%timestamp%-Robotium_Em_logcat.txt"
adb -s emulator-5554 shell logcat -c
adb -s emulator-5556 shell logcat -c
adb -s emulator-5556 shell am instrument -w com.example.nicho.pleasework.test/android.test.InstrumentationTestRunner
set timestamp=%date:~-4,4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%%time:~6,2%
adb -s emulator-5556 logcat -d -v time MyTest:I > "C:\Users\nicho\Desktop\logs\nexus4\%timestamp%-Nexus_4_logcat.txt"
adb -s emulator-5556 shell logcat -c
Related
Hi guys am new to the shell scripting.. please do not mind if acted like a noob.
The following error keeps poping up when am trying to run the shell script on my android device
#!/bin/bash
for i in $(seq 100)
do
echo "Time: $i"
adb -s $* shell am start com.android.camera/.Camera -W -S
adb -s $* shell sleep 3
adb -s $* shell input tap 540 1994
adb -s $* shell input tap 540 1994
adb -s $* shell input tap 540 1994
count=`adb -s $* shell ls /sdcard/DCIM/Camera/ | wc |awk '{print $1}'`
echo Count: $count
if [[ count -gt 500 ]]; then
break
fi
adb -s $* reboot
adb -s $* wait-for-device
adb -s $* shell sleep 40
adb -s $* shell input tap 500 1200
done
Result:
adb.exe: unknown command am
adb.exe: unknown command sleep
you can't run adb commands on your android device. instead the adb binary must installed on host. the script is a linux script and can not run from windows. prepare bootable usb flash drive and run this script from any linux terminal
furthermore some of your commands requires root permissions. therefore sush must invited (and permissions granted on superuser app on touchscreen)
adb shell su -c "am start com.android.camera/.Camera -W -S"
awk is not available on android. to make it more clear that these pipes are actually running on host, quote the android commands (or even better avoid awk at all)
count=$(adb shell "ls -1 /sdcard/DCIM/Camera" | wc | awk '{print $1}')
count=$(adb shell "ls -1 /sdcard/DCIM/Camera | wc -l")
am is actually a shell script pointing to am.jar this requires full booted android. if you try to run in recovery mode you should at least run the framework
I ran the following command in my terminal.
adb shell am start -S -W PackageName/.MainActivity
But,there is no output of time as expected.
Is there a way in adb to wait for a device with a particular name/id
I tried following so far
$adb wait-for-device emulator-5554
$adb wait-for-device -e emulator-5554
$adb wait-for-device - s shell emulator-5554```
but did not work
This should work
$ adb -s emulator-5554 wait-for-any-device
Can you help me please, my head is swollen...
I am trying to run daemon on android emu/device by command:
adb -s <device_name> shell su -c /dir/daemon <port_number>
but nothink happens, and no errors!
If I do:
adb -s <device> shell
and then form shell cmdline:
su -c /dir/daemon <port_number>
than its work fine. I try use shell-script and run:
adb -s <device_name> shell sh su -c /dir/script.sh <port_number>
and I even try to generate script from Qt code with port number and use:
adb -s <device_name> shell sh su -c /dir/script.sh
but its not helped... problem that if I enter to adb shell previous to run daemon - its work. Another problem is on different device/emu/iso_image different command format could not work. For example:
adb -s <device_name> shell su -c /dir/daemon <port_number> // work at emu, but not at iso
and vice:
adb -s <device_name> shell su -c "/dir/daemon <port_number>" // work at iso
etc.
Everybody can answer what's the matter?
Sorry for my english
adb shell su -c "/dir > /dev/null 2> /dev/null < /dev/null &"
or
shell su -c /data/local/tmp/start_daemon.sh
#!/system/bin/sh
/data/local/tmp/nohup
/data/local/tmp/daemon <portn_number> &
I write a alias command for get version of android in PC using adb shell, like this:
alias av="echo v:`adb shell getprop ro.build.version.release`;
echo sdk:`adb shell getprop ro.build.version.sdk`;
echo model:`adb shell getprop ro.product.model`;
echo display:`adb shell getprop ro.build.display.id`;"
I connect one device, it right outputs :
v:4.0.4
sdk:15
model:ZTE N983
display:N983V1.0.0B06
But when I change another device. It also output last text. When i open new shell, it output rights again. Why?
Alias has a cache? How to solve it ?
Thanks.
Backticks are evaluated immediately.
Use something like
alias av="echo -n v; adb shell getprop ro.build.version.release; ..."
to make the adb commands be executed at the time of alias execution.
The final result
1 alias av="echo -n v:; adb shell getprop ro.build.version.release; echo -n sdk:;adb shell getprop ro.build.version.sdk; \
echo -n model:;adb shell getprop ro.product.model; echo -n display:;adb shell getprop ro.build.display.id";
2 alias av='echo v: adb shell getprop ro.build.version.release; echo sdk: adb shell getprop ro.build.version.sdk; echo model: adb shell getprop ro.product.model; echo display: adb shell getprop ro.build.display.id'
But The second way cannot begin a new line using \