Reputation: 159
./a.out
Please select either 1 or 2:
this will do something
this will do something else
Then when I enter '1', it will do its job. I don't have the code itself but just binary so can't change it. I want to write a shell script which runs a.out and also inserts '1' in.
./a.out 1
./a.out << 1
./a.out < 1
but don't work. Could you please let me know if there is any way to write such as shell script? Thanks, dbm368
Upvotes: 0
Views: 767
Reputation: 9422
I think you just need a pipe. For example:
echo 1 | ./a.out
In general terms a pipe takes whatever the program on the left writes to stdout
and redirects to the stdin
of the program on the right.
Upvotes: 1