I have Python script that takes a User input during runtime and gives some outputs. Example code:
import random
l1 = ['Bob', 'Eric', 'Dimitar', 'Kyle']
l2 = ['Scott', 'Mat', 'Con']
n = raw_input('Enter no. of persons: ')
for i in range(int(n)):
print random.choice(l1) + ' ' + random.choice(l2)
Output:
$ ./generate_name.py
Enter no. of persons: 2
Kyle Scott
Eric Mat
Now I want to write another Python script that would run the first python script multiple times with a specific input (the input sequence is stored in a list) and record the outputs in file. Moreover, I can't make any changes in the first Python Code.
I can use the subprocess
module to run the script and record the output but how do I take care of the interactive User input part?