I am trying to automate the following task from the command line:
# ./
# exectuable prompts for input "Gimmie a value"
# I type and hit enter
# executable prompts for input "Gimmie another"
# I type 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.
Re: script provides input for executable
am 01.04.2008 00:11:52 von Hans-Peter Sauer
In news:738ba08b-e693-44dd-8feb-201406595935@x41g2000hsb.google groups.com,
Christopher typed:
> # ./
> # exectuable prompts for input "Gimmie a value"
> # I type and hit enter
> # executable prompts for input "Gimmie another"
> # I type 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.