Saving stdout from subprocess.Popen to file, plus writing more stuff to the file

后端 未结 4 1509
谎友^
谎友^ 2020-12-28 14:58

I\'m writing a python script that uses subprocess.Popen to execute two programs (from compiled C code) which each produce stdout. The script gets that output and saves it to

4条回答
  •  温柔的废话
    2020-12-28 15:24

    I say just keep it real simple. Pseudo code basic logic:

    write your start messages to logA
    execute A with output to logA
    write your in-between messages to logB
    execute B with output to logB
    write your final messages to logB
    when A & B finish, write content of logB to the end of logA
    delete logB
    

提交回复
热议问题