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()
It gives no error but it just enters root at my emulator and nothing else.
root@android:/ #
You call the
root
functionroot()
, which drops you into the adb shell. You are trying to run apython
commandinput
from the adb shell which will not work.A couple of links to help do what you want:
runpythonfromshell
sl4a