python3 excute shell script

@retry()
def doShellThread():
    # command='ping qq.com -t'
    # popen = subprocess.Popen(command, shell=True, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1)
    # for line in iter(popen.stdout.readline,'b'):
    #     if len(line)==0:break
    #     print(line.strip())

    command='ping qq.com'
    popen = subprocess.Popen(command, shell=True, universal_newlines=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1)
    out, err = popen.communicate()
    print('std_out: ' + out)
    print('std_err: ' + err)
    print('return code: ' + str(popen.returncode))

 

你可能感兴趣的:(python3 excute shell script)