0

I am running into a strange issue, running adb shell sendevent x x x commands from commandline works fine, but when I use any of the following:

subprocess.Popen(['adb', 'shell', 'sendevent', 'x', 'x','x'])
subprocess.Popen('adb shell sendevent x x x', shell=True)
subprocess.call(['adb', 'shell', 'sendevent', 'x', 'x','x'])

They all fail - the simulated touch even that works in a shell script does not work properly when called through python. Furthermore I tried adb push the shell script to the device, and using adb shell /system/sh /sdcard/script.sh I was able to run it successfully, but when I try to run that commandline through python, the script fails.

What's even stranger, is that he script runs, but for example, it does not seem to execute the command sleep 1 half way through the script, echo commands work, sendevent commands don't seem to work.

Doesn't even seem possible, but there it is. How do I run a set of adb shell sendevent x x x commands through python?

MishaP
  • 370
  • 1
  • 5
  • 13
  • Do any adb commands work from Python? Perhaps it is not in your path. – Dan Hulme Aug 23 '13 at 16:34
  • Don't you have to set the stdout=subprocess.PIPE for this? – ott-- Aug 23 '13 at 18:00
  • yes all other adb commands work. I don't think I need stdout=subprocess.PIPE, all that does is allow me to see the output of that command, and/or use the output in my code, which I don't need because there is no output... right? – MishaP Aug 27 '13 at 21:13

0 Answers0