script provides input for executable

I am trying to automate the following task from the command line:

# ./<executable name>
# exectuable prompts for input "Gimmie a value"
# I type <input> and hit enter
# executable prompts for input "Gimmie another"
# I type <input2> and hit enter
# executable exits

I know how to pass arguments, but I do not know how to automate input
after prompts. Can anyone help out?

I was told to look up "Expect", but my environment doesn't seem to
have it and I cannot alter it, as it is provided to me by my employer.
christopher [ Mo, 31 März 2008 20:48 ] [ ID #1931352 ]

Re: script provides input for executable

In news:738ba08b-e693-44dd-8feb-201406595935 [at] x41g2000hsb.google groups.com,
Christopher <cpisz [at] austin.rr.com> typed:

> # ./<executable name>
> # exectuable prompts for input "Gimmie a value"
> # I type <input> and hit enter
> # executable prompts for input "Gimmie another"
> # I type <input2> and hit enter
> # executable exits
>
> I know how to pass arguments, but I do not know how to automate input
> after prompts. Can anyone help out?

In addition to the "here" document that another suggested, you can:

echo -e "input\ninput2\n" | ./executable name

You should learn that the < > # you're in the habit of using have particular
meaning to the shell and should be avoiding in the interests of clear
communication, unless you intend them to have such meaning.
Hans-Peter Sauer [ Di, 01 April 2008 00:11 ] [ ID #1932340 ]
Linux » comp.unix.shell » script provides input for executable

Vorheriges Thema: is it possible to stop after find command finds one result
Nächstes Thema: How To Debug a Running Shell Script