Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send input into shell command?

Status
Not open for further replies.

redsss

Programmer
Mar 17, 2004
72
US
There is a command that prompts 4 times for user input, and at each prompt, I hit enter.

how can I automate that in a script?
 
Perhaps something like this:
echo "\n\n\n\n" | yourCommand

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
For more complex tasks, there is a tool called expect.
[tt] expect ? programmed dialogue with interactive programs[/tt]

--
 
Well for a simple script echo doesn't seem to work (this is on Linux, which doesnt include expect)
Code:
#!/bin/sh
echo in:
read INPUT
echo out:
read OUTPUT

echo you entered $INPUT and $OUTPUT
echo "2\n4\n" doesnt work.
but printf "2\n4\n" works.
But printf doesnt work for the executable I need it to work with, which is openssl.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top