Reputation: 31
Hi have an easy C program that does the following when I run it with ./a.out
Please enter your name:
What I want to do, is I want to automatically pass the name without having to wait for the prompt. I tried ./a.out Sam, but it would still prompt for a name. I'm trying to write a bash script that would do that.
Any help would be appreciated. Note: I don't want to modify the C source. All I want to do is be able to pass the first argument without having to wait for the prompt.
Upvotes: 0
Views: 65
Reputation: 158060
The program reads from stdin
. You can pipe to stdin:
echo "Sam" | ./a.out
Upvotes: 4