使用adb的Python连续子进程调用
我正在尝试制作一个python脚本来通过adb检查数据库的内容。关键是在我的代码中,仅执行第一个subprocess.call(),其余的都被忽略。由于我是Python的新手,所以我不确定如何修复它。这是代码:
I am trying to make a python script to check the contents of a database via adb. The thing is that in my code,only the first subprocess.call() is executed and the rest are ignored. Since i am fairly new to Python, i am not sure how to fix it. This is the code:
import subprocess
def root():
subprocess.call('adb shell',shell=True)
x=input('Enter package name: ')
openSql(x)
def openSql(x):
subprocess.call('cd data/data/%s/databases/'%(x),shell=True)
table=input('Enter table name: ')
openTable(table)
def openTable(table):
subprocess.call('sqlite3 table',shell=True)
subprocess.call('select * from %s'%(table),shell=True)
root()
它给出没错,但是它只是在我的仿真器中进入了root用户。
It gives no error but it just enters root at my emulator and nothing else.
root@android:/ #
您称 root
函数 root()
,将您带到adb shell中。您正在尝试从adb shell运行 python
输入 input
的命令,该命令将不起作用。
You call the root
function root()
, which drops you into the adb shell. You are trying to run a python
command input
from the adb shell which will not work.
几个帮助您完成所需操作的链接:
A couple of links to help do what you want: