oshipka/util/os.py

19 lines
508 B
Python
Raw Normal View History

2020-05-11 20:29:25 +02:00
import subprocess
def run_cmd(command):
process = subprocess.Popen(command.split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
return '\n'.join([str(line) for line in iter(process.stdout.readline, '')])
def print_cmd(command):
for line in run_cmd(command):
print(line, end='')
if __name__ == "__main__":
print_cmd("env")