I am having a C program which requires to read from stdin. This is one of the requirements, and it cannot change.I have written a simple bash script that creates all the directories I want, handles the output etc. and also compiles and runs my program.When I run my program it waits for the user to give an input from the stdin :I want to be able to give that input from the bash - so do not let the user give the input (there is a reason for that). So ideally, I want somehow the input to be visible to the user but given from the script.If I write something like this :./task2cat <<< my input hereIt runs the task, and the cat command runs when the task has finished. I want somehow to enforce that cat whenever the program requires input from the user.Is it possible?
Bash script and stdin
bash;stdin
If I understood you correctly, you can use tee for this purpose. In the Bash script, let's assume the following line runs your compiled C program:./my_programReplace that with:printf %s\n my input here | tee /dev/tty | ./my_programThis will print my input here to your terminal device and pipe it to ./my_program on its stdin so it can read it.