I can do this:

adb exec-in "gzip > sdcard/test.gz" < C:\test.txt
adb exec-out cat sdcard/test.gz > C:\test.gz

The question is how to do something like this:

adb exec-in "gzip > C:\test.gz" < C:\test.txt

I mean, how can I use a file on my PC as an input for some android (linux) program and use another file on my PC as an output WITHOUT saving any data on android's internal memory (flash, microSD etc)?

  • exec-in and exec-out can write/read to/from only files, not STDOUT/STDIN: android.googlesource.com/platform/system/core/+/…. However you can use shell: adb shell gzip >C:\test.gz <C:\test.txt. This will write nothing to Android device. However this is not the recommended method. Some unwanted characters may get included when reading/writing to terminal. Btw, what command from Android do you want to use on PC? Why don't you get that on PC? – Irfan Latif Jun 10 '19 at 20:16
  • The command adb shell gzip >C:\test.gz <C:\test.txt creates a test.gz file, which is the same like test.txt, not an archive. Also the shell hangs (need Ctrl+C press). Thank you for information, that exec-in and exec-out can't use STDOUT/STDIN. – Rutius Jun 10 '19 at 21:25
  • Right, that would be the case if you are on Windows PC. Windows' handling of terminal related stuff is poor. adb would not be forwarding data read from test.txt to STDIN of shell (/system/bin/sh)`. I just tested it on Linux/Android and it works. – Irfan Latif Jun 10 '19 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.