Why can I not pipe into adb shell
?
[klm@kth ~]$ echo foo | adb shell cat
^C
The above command hangs on my 4.0.1 emulator, and I'm not seeing the expected foo
output.
I presume it's because adb shell
doesn't pipe its stdin into its child-process' stdout, and cat
sits and waits forever. Has this really not been implemented in adb
, or am I missing something?
Here's my solution. Put the following into the
adb_shell.sh
file and use it instead ofadb shell
:This creates an
nc
listener which runs the specified command upon the connection, and then connects to it.An alternate option may be to use adb port forwarding and netcat.
Set Android side to recieve:
PC side, set forwarding and send:
The PC netcat connects to the Android netcat through the forwarded port, and the
piped_file.txt
is delivered.Additional Info
Combined with tar, you can copy entire directory structures onto your device.
busybox nc -lp 5555 | tar -x # Android side
This is correct. This functionality has not been implemented.
Update:
A lot of bugs have been fixed and new features implemented in
adb
since the time the original question had been posted. Including support for properstdin
handling byadb shell
. So there is no need for thenetcat
workarounds anymore.