python 与ADB shell交互
来源:互联网 发布:sql server 创建表语句 编辑:程序博客网 时间:2024/06/05 06:29
python交互
使用subprocess
使设备具有部分Linux命令
python脚本:下载busybox,并且放在与脚本相同的目录下
# coding:utf-8# 这个脚本用于使环境拥有busybox的环境import subprocessimport osprint "开始push文件"os.system(" adb push busybox /system/xbin/")print "开始root"os.system("adb root")print "开始remote"os.system("adb remount")#这里面的命令全部都会在Linux的环境下执行,最后需要退出。cmds = [ "chmod 755 /system/xbin/busybox", "cd /system/xbin/", "busybox --install .", "awk", "ps |grep com.txznet.music|awk '{print $2}' | head -n 1", "exit",#这是是非常关键的,退出]print "开始安装"pipe = subprocess.Popen("adb shell", stdin=subprocess.PIPE, stdout=subprocess.PIPE)code = pipe.communicate("\n".join(cmds) + "\n");print codeprint "安装结束"
杀掉相应的进程
# coding:utf-8# 这个脚本是用来杀掉music的进程的import osimport stringimport subprocessdef kill(result): print result.strip() code = os.system(" adb shell kill " + result.strip()) print codeprocessname = os.system('''adb shell ps|grep com.txznet.music|awk '{print$2","}''''')# print processname# result="["+str(processname)+"]"# print result# for processID in result:# print processID.strip()# code=os.system(" adb shell kill "+processID.strip())# print codepipe = subprocess.Popen("adb shell ps|grep com.txznet.music|awk '{print$2}'", stdin=subprocess.PIPE, stdout=subprocess.PIPE)# result=pipe.communicate("ps|grep com.txznet.music|awk '{print$2","}'")# print resultresult = pipe.stdout.readline()result1 = pipe.stdout.readline()result2 = pipe.stdout.readline()print resultkill(result)print result1kill(result1)print result2kill(result2)
0 0
- python 与ADB shell交互
- [Python]与shell交互
- Python与shell交互方式
- Shell 与Python的交互
- Python与shell的交互方式
- Python与shell的3种交互方式介绍
- 通过adb shell命令查看当前与用户交互的activity
- Python.PyADB -- Python的ADB交互接口
- shell 与 sqlplus 交互
- PHP与Shell交互
- shell 与 sqlplus 交互
- shell 与 sqlplus 交互
- shell 与 sqlplus 交互
- PHP与Shell交互
- Python execute adb shell command
- awk 与 shell 交互方式
- AWK----awk与shell交互
- linux shell 与sqlplus交互
- Chrome 标签跳转
- runtime运行时的用法(一)
- 欢迎使用CSDN-markdown编辑器
- 【语言-C++】调试运行(在vs)Debug和Release 、以及独立运行Debug无错误,独立运行Release却出现崩溃
- linux基础知识
- python 与ADB shell交互
- java使用jdom生成xml格式文件
- Stanford机器学习 第一周:机器学习概念及单变量线性回归
- 第十八章 集合Collection2
- Linux系统(三)系统基础扫盲大全
- HttpClient和HttpURLConnection
- 九大排序算法再总结
- Linux下文件,文件夹权限讲解
- gcj 2017 A