I'm trying to run an exe through python and dump both user input and output to a log file.
Source file for exe:
//test.c
#include<stdio.h>
void main()
{
int a=0;
printf("Enter no:\n");
scanf("%d",&a);
printf("You entered %d",a);
}
after compiling the above file, I tried to run test.exe through python
#Dumpinputoutput.py
file="log.txt"
fo=open(file, "w")
subprocess.call(["test.exe"],stdout=fo,stderr=fo)
fo.close()
On executing the script,
log.txt was:
Enter no:
You entered 54
Instead of
Enter no:
54
You entered 54
I want the user's input also to be included in the log file, is it possible?
I tried subprocess.peopen also, but getting the same.