[英]android -> how to run python script as root?
How can I run a python script as root in Android ? 如何在Android中以root身份运行python脚本? I made a simple python script and placed it in /data/data/py.test/pyshell.py the content of pyshell.py is 我做了一个简单的python脚本并将其放在/data/data/py.test/pyshell.py中,pyshell.py的内容是
import os
os.system('am start -d "http://www.stackoverflow.com"')
If I try the command "python /data/data/py.test/pyshell.py" It should normally start the web-browser but it doesn't. 如果我尝试执行命令“ python /data/data/py.test/pyshell.py”,它通常应该启动Web浏览器,但不会启动。 I just get an message: Starting: Intent {dat= http://www.stackoverflow.com } 我刚收到一条消息:开始:意图{dat = http://www.stackoverflow.com }
But if I go to Terminal Emulator and write: 但是,如果我去终端仿真器并写:
su
python /data/data/py.test/pyshell.py
I get root rights and the browser starts. 我获得root权限,浏览器启动。 So the problem must be with root. 因此问题必须出在根本上。
How can I give "/data/data/py.test/pyshell.py" automatic/always root access. 如何授予“ /data/data/py.test/pyshell.py”自动/始终具有根访问权限。
As this will execute Linux command enter 由于这将执行Linux命令,请输入
os.system("su")
If properly rooted you will get prompt..... 如果扎根正确,您将得到提示.....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.