Pipe into `adb shell`

前端 未结 3 765
萌比男神i
萌比男神i 2021-02-14 06:29

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

3条回答
  •  鱼传尺愫
    2021-02-14 07:32

    Here's my solution. Put the following into the adb_shell.sh file and use it instead of adb shell:

    #!/bin/bash
    
    adb forward tcp:12345 tcp:12345
    adb shell busybox nc -lp 12345 -e "$@" &
    sleep 1s
    exec nc -q 1 localhost 12345
    

    This creates an nc listener which runs the specified command upon the connection, and then connects to it.

提交回复
热议问题