Python Calling Raw_input From A Subprocess
I'm calling a python script from the below one using subprocess. From the command line the user chooses which file to open using raw_input import optparse import subprocess import
Solution 1:
Here's an example where the subprocess receives my input:
import subprocess
import sys
command = 'python -c \'print raw_input("Please make a selection: ")\''
sp = subprocess.Popen(command, shell = True, stdin = sys.stdin)
sp.wait()
Solution 2:
If I understand your question, you want to redirect the current standard input to the subprocess. Which can be done this way:
subprocess.Popen(file, stdin=sys.stdin, ...)
Post a Comment for "Python Calling Raw_input From A Subprocess"