Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

bash - adb.exe: unknown command am adb.exe: unknown command sleep error keeps poping up when am trying to run the shell script on my rooted android device

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

question from:https://stackoverflow.com/questions/65908681/adb-exe-unknown-command-am-adb-exe-unknown-command-sleep-error-keeps-poping-up

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...