1

I'm trying to execute command to adb shell from python I'm using Windows OS

On CMD :

C:\Users\deounix>adb shell
shell@android:/ $ su root
su root
root@android:/ # reboot

What I'm doing is :

import os

os.popen("adb shell & su root & reboot")

But it isn't work

How can I do it?

3
  • I did this in the past, I do not remember how I did it, but I remember there is a way to start the second process and later on to send to it input data and catch its output. Commented Jul 30, 2015 at 12:50
  • @MihaiHangiu How can I do this ? Commented Jul 30, 2015 at 13:02
  • use subprocess instead. also adb reboot without shell does not require root: subprocess.check_output(['adb', 'reboot']) Commented Jul 30, 2015 at 14:14

2 Answers 2

5
import os
os.system("adb shell su -c reboot")
Sign up to request clarification or add additional context in comments.

3 Comments

no it can't be like this, because it's do first command : adb shell then it isn't do : su root inside adb shell
Call: adb shell; su root; reboot instead
Ah, right. Need the path. No matter. Updated answer with a command that works.
-1
import os
os.system("c:/platform-tools/adb devices")

To run any command like adb devices on python execute the above command This will work definitely. You just need to confirm the path where you have got the adb shell

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.