简体   繁体   中英

Unable to get an ADB shell command with a path working within a Windows shell

I'm trying to get the color of a pixel from a screendump. While I can get the command to work when I use 'adb shell' first, I want to be able to run the command right from a windows shell. I've tried all the suggestions in this post , but I can't get it to work.

"C:\\Program Files\\Microvirt\\MEmu\\adb.exe" -s 127.0.0.1:21503 shell dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd

This returns

'the system cannot find the path specified'

If I try:

"C:\\Program Files\\Microvirt\\MEmu\\adb.exe" -s 127.0.0.1:21503 shell \\"dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd\\"

It returns:

/system/bin/sh: dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd not found

The sh file does exist in /system/bin/ so I have no idea what's going on.

You don't need to escape the " character for entering command for adb shell .

"C:\Program Files\Microvirt\MEmu\adb.exe" -s 127.0.0.1:21503 shell "dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd"

will be OK.

Besides, your comment said,

That folder is already in my PATH environmental variable.

Then you don't need to specify the full path to adb .

adb -s 127.0.0.1:21503 shell "dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd"

is OK, too.


The error message,

/system/bin/sh: dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd not found

indicates that there is no executable called "dd if='/sdcard...null | hd", but you are just need them as parameters, not a full executable name.


For your first attempt,

"C:\Program Files\Microvirt\MEmu\adb.exe" -s 127.0.0.1:21503 shell dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd

This command will regard hd outside of the adb shell , it is going to execute by the command line of Windows.

Update : We can use the parameter of od or hd to do some tricks.
For example, on my device, busybox od has the parameter [-t TYPE] , [-A RADIX] , [-N SIZE] and [-j SKIP] , then on my phone I can do

adb shell od -N4 -j54950 -tx1 -Ax /sdcard/screen.dump

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM