I am running a python script via terminal. The script contains a main function. It runs other programs in some directory and all those programs are in Python too.
While running these sub programs, I need to enter their required input values in the terminal using this main program(not command line arguments).
Ex:
MainProgram calls --dir1/pg1.py
----inputs 10 20 30
Main program calls --dir1/pg2.py
----inputs 100 20 30 like wise the inputs to the subprograms are to be given by the main program.
I am trying to automate the process of giving input to a program and I need to do it with the help of a program. Ex: the given below is a simple program for finding factorial
i=1
fact=1
num=input("Enter the num : ")
while i<=num:
fact*=i
i+=1
print fact
I need a program(say MainProgram.py) that on execution calls the above program and give the required input to it and gets the output and validates if it is right or not.
Please help me with this. Been searching for a solution for long.