I found out how to automatically send input to a C program using Shell Script. For example, if I compile this C program:  //test.cint main()}    int x;    printf(Please enter an integer:);    scanf(%d, &x);  printf(\nYou entered %d\n, x);}and write this script:  #!/bin/bash./test << EOF5EOFand open the terminal and run the script I will get this output:  Please enter an integer:You entered 5Now, I want test to run on a new terminal, which I found out that I can do with this command:gnome-terminal -x ./testThe problem is, if I try to do both at the same time in my script (run test on a new terminal AND automatically send input), it doesn't work, the input doesn't get sent on the new terminal, you just have to give it yourself like you normally would.What am I doing wrong and how to fix this?P.S. Sorry if the format is a bit messed up, I tried.
How to send input in a new terminal using Shell Script
shell;scripting;input
It will work if you use your shell script rather than the binary.$ ~/tmp/term_test$ cat ./test_wrapper.sh #!/bin/bash ./test << EOF5 EOFread dummy$ gnome-terminal -x  ./test_wrapper.sh $ The read dummy line I added will stop the terminal from immediately closing when the script completes.Are you sure that you need to open a new terminal session?