stdout2stderr.py 423 B

1234567891011121314
  1. import subprocess
  2. import sys
  3. FILE_PARAM = '--file='
  4. if __name__ == '__main__':
  5. i = 1
  6. stdout = sys.stderr
  7. if len(sys.argv) > i and sys.argv[i].startswith(FILE_PARAM):
  8. file_name = sys.argv[i][len(FILE_PARAM) :]
  9. stdout = open(file_name, "w")
  10. i += 1
  11. assert len(sys.argv) > i and not sys.argv[i].startswith(FILE_PARAM)
  12. sys.exit(subprocess.Popen(sys.argv[i:], stdout=stdout).wait())