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.
You call the
root(), which drops you into the adb shell. You are trying to run a
input from the adb shell which will not work.
A couple of links to help do what you want:
<a href="http://code.google.com/p/python-for-android/wiki/RunPythonFromShell" rel="nofollow">runpythonfromshell</a>
<a href="http://code.google.com/p/android-scripting/wiki/UserGuide" rel="nofollow">sl4a</a>Answer2: