0

One problem with ADB is that you need multiple commands to get things done. For example:

adb shell

su 

cp /data/local/x /data/local/y

exit

adb pull /data/local/y

Can this be done using python popen and os-system? Tried the example below without success..

print 'Starting emulator...'
subprocess.Popen(['emulator', '-avd', 'testavd'])
os.system('adb wait-for-device')
os.system('Perform whatever adb commands you need')

Any pointers?

1 Answer 1

3

You can simply do:

adb shell su -c cp /data/local/x /data/local/y
adb pull /data/local/y

or, if you want to run more than one command (only Linux & OSX):

adb shell <<EOF
ls
date
cat /proc/version
exit
EOF
Sign up to request clarification or add additional context in comments.

2 Comments

I would need to find a way to do this on Windows ... maybe cygwin?
type script.txt | adb shell; maybe ?

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.