首页 > 解决方案 > 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.

标签: androidwindowsshelladb

解决方案


您无需转义"字符即可输入命令 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"

会好的。

此外,你的评论说,

该文件夹已经在我的 PATH 环境变量中。

然后,您无需指定adb.

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

也OK。


错误信息,

/system/bin/sh: dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | 找不到高清

表示没有名为“dd if='/sdcard...null | hd”的可执行文件,但您只需要它们作为参数,而不是完整的可执行文件名称。


对于您的第一次尝试,

"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

该命令将在 .NEThd之外adb shell,它将由 Windows 的命令行执行。

更新:我们可以使用odor的参数hd来做一些技巧。
例如,在我的设备上,busybox od有参数[-t TYPE], [-A RADIX], [-N SIZE]and [-j SKIP],然后在我的手机上我可以

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

推荐阅读