I am trying to execute adb shell commands in python using subprocess.Popen
Example: Need to execute 'command' in adb shell. While executing manually, I open the command window and execute as below and it works.
>adb shell
#<command>
In Python I am using as below but the process is stuck and doesn't give output
subprocess.Popen('adb shell <command>)
Tried executing manually in command window, same result as python code,stuck and doesn't give output
>adb shell <command>
I am trying to execute a binary file in background(using binary file name followed by &) in the command.
Found a way to do it using communicate() method in subprocess module
Ankur Kabra, try the code below:
and you will see the error output.
Usually it will tell you:
which means, shell can not excute
adb
command. so, addingadb
to yourPATH
or writing the full path ofadb
will solve the problem.May help.
use pexpect (https://pexpect.readthedocs.io/en/stable/)