Issue
import subprocess
while True:
subprocess.call(input("> "), shell=True)
let's say when I run adb shell settings get system volume_music_speaker
, how can I get the console output and store it, which let's say, it's max volume so the return value would be 14. I have already tried
while True:
a = subprocess.call(input("> "), shell=True)
print(a)
but I always get 0. Thank you.
Solution
https://docs.python.org/3/library/subprocess.html#subprocess.PIPE
with subprocess.Popen(input("> "),
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as your_process:
output, err = your_process.communicate()
Answered By - Anonymous
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.