2

I've got two scripts, both run from the windows command line (they contain argparse objects).

These interact in the following way: The first script determines which parser arguments to hand to the second script, it then formats them correctly and hands them to the second script through some form of subprocessess.call() arrangement.

When the second script requires no user interaction through the command line this all works fine. When the user is prompted for inputs by the seconds script as part of its processing, however, it all locks up.

How can I interact with the second script through the same command line that I'm running the first script in?

The second script can be one of several different ones, so any method would have to be flexible enough to handle passing any arguments to any script

Cheers

7
  • 2
    Don't use subprocess.call, but just import the second script, and run the necessary functions Commented Apr 28, 2016 at 12:24
  • Sorry, I've just updated the question slightly. The second script isn't always the same. Surely I'd have to hard-code the importing of the scripting functions that I wanted to use? The great benefit of the subprocess is that by passing a cmd line argument I can use any script and any arguments Commented Apr 28, 2016 at 12:34
  • In that case, use the answer from here, basically, add an stdin = sys.stdin argument to subprocess Commented Apr 28, 2016 at 12:36
  • Amazing, thanks! How does that work? Would stdout=sys.stdout also help? Commented Apr 28, 2016 at 12:50
  • You can dynamically import scripts in Python, ya know Commented Apr 28, 2016 at 12:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.