For better understanding,
example2.py
a = raw_input("Enter 1st number: ") b = raw_input("Enter 2nd number: ") *some code here* c = raw_input("Enter 3rd number: ") s = a+b+c print(s) example1.py
import os os.system('python example2.py') <need logic to address the input prompts in example2.py> <something to pass like **python example2.py 1 2 3**> I guess by looking at these scripts you can get it what I'm looking for? Let me explain it once for a better understanding. There are two files example1.py and example2.py. Now, I called example1.py from my shell, which in turn called the other script and waiting for the input.
Notes:
- I can't do anything on
example2.py, which is not owned by me. - I'm limited to do changes on
example1.pyand pass arguments toexample1.py - I know there will be a process created for
example2.py, but not sure about passing these arguments to process IO. - Actual code was different, I crafted
example1.pyandexample2.pyfor the sake of understanding.
I couldn't grasp any ideas from these links:
Launch a python script from another script, with parameters in subprocess argument
how to execute a python script file with an argument from inside another python script file
Please share your thoughts on this and help me to resolve this. Please don't mind editing the question if it requires. I'm completely new to the module os, subprocess.
Popen& use thecommunicatemethod to pass strings to the stdin of the process