So I have a program that takes in user input and outputs text based on the input.
EDIT2: I want to create a script that runs a C executable and the script feeds the C program input from a file and redirect output to another file. HOWEVER I want to also print out the input whenever an output was printed for input basically combining/merging the input and output together. So I feed it input line by line in a file and then print output to a file for every input and I keep doing this. I do not want to re-run the program I want the program to still be running until it reaches the end of the input file or until I send it a kill signal from the script. (I'm trying to make a grading script for a class. Students submit their programs and I run this script and I feed input to their programs but I want to keep track of the input + output together so it makes it easier for me to keep track of the input for each of their output) I can figure out how to create the rest of the script myself but I'm just stuck at combining input + output together.
Edit3: I don't think expect will work because I have no way of knowing what the program will output. I only know what it's suppose to take in. For example one student might have a program say "Give me a character:" while another will say "Enter a char-" so I don't know what to expect from these programs.
(Note: I will have many different executable that will have different format but should all ask for same amount of input)
For example, one of the executable could be this:
"Enter a number: " (Wait for user input) "Give another: " (Wait for user input "Total: " (Output based on input) "Do you want to run again? "(Wait for user input)
EDIT: My main goal of my script is to run the program taking in input from a file line by line. For example for this program I will want it to take in the file "input" as stdin but I also want to keep track of the stdin merged with the stdout.
So I know ./a.out < input > output will output
Enter a number: Give another: Total: 15 Do you want to run again?
However it's missing the input which is what I want included also so I can tell what the input was based on the output just by looking at the output file ONLY because the input could be 7 8 N or 5 10 N or anything like that.