|
From: Christopher on 31 Mar 2008 14:48 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.
From: OldSchool on 31 Mar 2008 16:09 On Mar 31, 2:48 pm, Christopher <cp...(a)austin.rr.com> wrote: > 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. Take a look at "here-docs" ./your_exec <<eof_mark input1 input2 eof_mark should be in the man page for your shell
From: mop2 on 31 Mar 2008 16:26 # Perhaps a way: $ cat s read -p a: a read -p b: b $ ./s a:1 b:2 =1=2= $ echo -e '3\n4'|./s =3=4=
From: h.stroph on 31 Mar 2008 18:11 In news:738ba08b-e693-44dd-8feb-201406595935(a)x41g2000hsb.googlegroups.com, Christopher <cpisz(a)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.
|
Pages: 1 Prev: Need help with grep Next: How to filter out without country's line ? |