Skip to content

Instantly share code, notes, and snippets.

@qtfkwk
Last active August 31, 2021 18:48
Show Gist options
  • Save qtfkwk/696d250c48f37095b4916bb13e052b5a to your computer and use it in GitHub Desktop.
Save qtfkwk/696d250c48f37095b4916bb13e052b5a to your computer and use it in GitHub Desktop.
ez command runner
from subprocessing import Popen, PIPE
class run:
def __init__(self, cmd, stdin=None, ttl=None):
self.cmd, self.stdin, self.ttl = cmd, stdin, ttl
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
self.stdout, self.stderr = p.communicate(stdin, ttl)
self.code = p.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment