oshipka/util/os.py
2020-06-03 16:00:51 +02:00

19 lines
508 B
Python

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")