1

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.

Joe Briggs
  • 11
  • 4
  • `adb shell dd if='/sdcard/screen.dump' bs=4 count=1 skip=54950 2>/dev/null | hd` returns the same error that the system cannot find the path specified. The folder containing adb.exe is spelled MEmu (it's an emulator). That folder is already in my PATH environmental variable. Other commands like `adb shell screencap /sdcard/screen.dump` work just as expected. – Joe Briggs Mar 12 '19 at 04:47

1 Answers1

-1

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
Geno Chen
  • 4,916
  • 6
  • 21
  • 39
  • @JonGoodwin This is the original author's configuration for connecting ADB to a device, maybe there is an emulator on the same machine. So I just keep it. – Geno Chen Mar 12 '19 at 06:05
  • @JonGoodwin I am not sure if the original author's inbox will have messages for our comment**s**... But, we know, when he come back to this question, he will see our answers and comments. Besides, there will be an error if I try to mention two people, "Only one additional @ user can be notified; the post owner will always be notified". – Geno Chen Mar 12 '19 at 06:27
  • @JonGoodwin Let's wait for the original author's return :-) – Geno Chen Mar 12 '19 at 06:35
  • 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: `Usage: hd [-b base] [-c count] [-r delay] file` – Joe Briggs Mar 12 '19 at 10:28
  • @JoeBriggs Then it's time to try how to use `hd` in your machine. For example use `busybox hd` or `hd -`? This is something more device specific. – Geno Chen Mar 12 '19 at 10:34
  • The MEmu android emulator is configured as a SM-G920F. `"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 | busybox hd"` returns: hd-: applet not found (even if I install busybox from the playstore).. – Joe Briggs Mar 12 '19 at 10:44
  • @JoeBriggs What about `busybox hexdump`? Or use `od`, for example `od -x`? – Geno Chen Mar 12 '19 at 10:46
  • Your suggestions are returning some interesting results. In comparison, if I run ADB shell first and then the command it returns: 0000000: 22 74 e6 ff s 27b sum 27b Now this is what your suggestions return: `"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 | busybox hexdump"` 0000000 7422 ffe6 0000004 `"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 | busybox od"` 0000000 072042 177746 0000004 – Joe Briggs Mar 12 '19 at 10:57
  • `"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 | busybox od -x"` 0000000 7422 ffe6 0000004 So even though the color info is returned in a different order, it is working. – Joe Briggs Mar 12 '19 at 10:58
  • Yes, that's it. `od` without parameter is an octal dump, and `hd` is an alias for `hexdump -C` on some devices, `hexdump` is a hexadecimal dump. – Geno Chen Mar 12 '19 at 11:02
  • " So even though the color info is returned in a different order, it is working", you may try to look for the parameters of `od` or `hd` for a better format. On my device, I can use `-N` and `-j` parameter of `od` to directly dump **part** of file, then the `dd` part is not necessary for me. – Geno Chen Mar 12 '19 at 11:04
  • "So even though the color info is returned in a different order, it is working." Try `od` with `-tx1` parameter. – Geno Chen Mar 12 '19 at 11:10
  • "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 | -tx1 od" Like that? It returns : system/bin/sh: -tx1 not found – Joe Briggs Mar 12 '19 at 11:26
  • @JoeBriggs Just a try for tuning the output format. You may try under the help of `--help`. – Geno Chen Mar 12 '19 at 11:28