Skip to content

Instantly share code, notes, and snippets.

@marius92mc
Created May 23, 2016 21:18
Show Gist options
  • Save marius92mc/664f006f885b694d8fb5ecb85839789d to your computer and use it in GitHub Desktop.
Save marius92mc/664f006f885b694d8fb5ecb85839789d to your computer and use it in GitHub Desktop.
import subprocess
def print_shell_command(cmd):
## run it ##
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
while True:
out = p.stderr.read(1)
if out == '' and p.poll() != None:
break
if out != '':
sys.stdout.write(out)
sys.stdout.flush()
print_shell_command("cd; cd Desktop; ls -lht | grep drw")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment