免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1373 | 回复: 0

一个关于subprocess的小问题 [复制链接]

论坛徽章:
0
发表于 2017-06-10 14:52 |显示全部楼层
本帖最后由 zhjwlgh01 于 2017-06-10 14:54 编辑

新人,想写个小脚本调用linux的脚本,但总是拿不到output的结果,求教~~感觉问题出在 p.stdout.readlines()特别说明下,那个脚本大概要运行20分钟,理论上有大量的输出的
testCommand = "adb shell su -c '/data/con.sh'"
p=subprocess.Popen(testCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
        buff = p.stdout.readlines();
        count = count + 1
        print str(count) + " : " + comm
        if buff.find("---Test finished---") >= 0:
                print buff,
                return 0
        elif buff.find("adb: error") >= 0:
                print buff,
                return 1
        if p.poll() != None:
                break;
        time.sleep(60);
        if (count > sleepTime):
                print "executeCommand time out";
                return 1;


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP