Skip to content

Instantly share code, notes, and snippets.

@kstohr
Created August 1, 2017 10:28
Show Gist options
  • Save kstohr/26cf1d389c689d11433bd560b42df0a1 to your computer and use it in GitHub Desktop.
Save kstohr/26cf1d389c689d11433bd560b42df0a1 to your computer and use it in GitHub Desktop.
Python subprocess to run a CLI python script in interactive mode
from subprocess import Popen, PIPE
cmd = 'python some_python_script.py'
p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
stdout.splitlines()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment