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
#
In Python I am using as below but the process is stuck and doesn't give output
subprocess.Popen('adb shell )
Tried executing manually in command window, same result as python code,stuck and doesn't give output
>adb shell
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
procId = subprocess.Popen('adb shell', stdin = subprocess.PIPE)
procId.communicate('command1\ncommand2\nexit\n')