运行带有蟒POPEN或使用os.system多个亚行命令 [英] Running multiple adb commands with python Popen or os.system

查看:215
本文介绍了运行带有蟒POPEN或使用os.system多个亚行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与亚行的一个问题是,你需要多个命令,把事情做好。
例如:

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

可以这样使用python的popen和OS系统做了什么?尝试下面的例子中没有成功。

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')

任何指针?

推荐答案

您可以简单地做:

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

或者,如果你想运行多个命令(仅适用于Linux和放大器; OSX):

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

adb shell <<EOF
ls
date
cat /proc/version
exit
EOF

这篇关于运行带有蟒POPEN或使用os.system多个亚行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆