Skip to content

Instantly share code, notes, and snippets.

View ekawahyu's full-sized avatar

Eka Susilo ekawahyu

View GitHub Profile
@ekawahyu
ekawahyu / subprocess_stdout_instantly.py
Last active October 7, 2024 04:52 — forked from thenger/subprocess_stdout_instantly.py
Python display subprocess stdout in real time
import os
import shlex
import subprocess
# Redirect stderr and stdout of a subprocess to the python ones
def exec_cmd_with_output(cmd):
stdoutlines = []
a_process = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in a_process.stdout: