How do I push a string to stdin? Provide input via stdin on startup, then read stdin input interactively
Is there a way to "push" a string to the stdin stream of a program when calling it? So that we would have the effect of echo "something" | ./my_program but instead of reading EOF after "something" , my_program would read its further input from the original stdin (e.g., the keyboard). Example: Say we want to start a bash shell, but the first thing we would like to do inside it is to call date . echo date | bash would not do the job, as the shell would terminate after running date . Jonathan Leffler This might work: (echo "something"; cat -) | ./my_program It creates a sub-shell where the first