How to Use Adb Shell When Multiple Devices Are Connected? Fails with "Error: More Than One Device and Emulator"

How to use ADB Shell when Multiple Devices are connected? Fails with error: more than one device and emulator

Use the -s option BEFORE the command to specify the device, for example:

adb -s 7f1c864e shell

See also http://developer.android.com/tools/help/adb.html#directingcommands

adb error: more than one device - android

I got it

C:\Users\MBH>adb devices -l
List of devices attached
0123456789ABCDEF device product:ZEN model:ZEN device:ZEN
0123456789ABCDEF device product:full_gs702c model:M757 device:gs702c

Then I could use the model number for shelling

C:\Users\MBH>adb -s model:M757 shell
shell@gs702c:/ $ ls

it works now

How to display my device Infomation on cmd(using adb)

You need to grep the values returns by adb shell getprop as in here.

For each value, you can set it in a variable, and then print it with the format you want.

Example:

model=$(adb shell getprop | grep model | cut -d ":" -f 2)
# Or, simpler
model=$(adb shell getprop ro.product.model)
echo "model='${model}'"

The OP 강승오 adds in the comments:

I got app ver from 'adb shell dumpsys package mypackage | grep"'versionName="' and I checked I want to display App ver : 1.2.345 but, displayed on result App ver : versionName=1.2.345.

how to solve this?

I tried set str command set str:%str:versionName=:% after then nothing displayed on app ver app ver : (blank).

If you have set that result to a variable, you can replace the part you don't want:

res=$(adb shell dumpsys package mypackage | grep"'versionName=")
res=${res/versionName=/}
echo "res='${res}'

adb shell check if screen is on windows cmd

Found solution

@echo off
cd /d "C:\Program Files (x86)\Remote\adb"

setlocal
for /f "delims= tokens=1*" %%a in ('adb shell dumpsys power ^| findstr.exe "mWakefulness=Asleep"') DO (
for /f "delims== tokens=2*" %%S in ("%%a") do (
if "%%S" == "false" (goto move1) else (goto move2)
)
)

:move1
goto end

:move2
start /MIN cmd /c adb shell input keyevent 26
goto end

:end
exit


Related Topics



Leave a reply



Submit