From: Kenny McCormack on 8 Aug 2010 20:12 In article <m3k4o1qg82.fsf(a)gmail.com>, WANG Cong <xiyou.wangcong(a)gmail.com> wrote: .... >I think that is not safe, there are a considerable amount of >Unix programs which don't work with Janis' solution, especially when >dealing with passwords, for example, passwd, su, rlogin etc.. >expect(1) always work, and it is not hard to write a simple expect >script to solve OP's problem. ITA! -- (This discussion group is about C, ...) Wrong. It is only OCCASIONALLY a discussion group about C; mostly, like most "discussion" groups, it is off-topic Rorsharch [sic] revelations of the childhood traumas of the participants...
From: Janis Papanagnou on 9 Aug 2010 02:46 WANG Cong schrieb: > On 08/04/10 20:33, blmblm(a)myrealbox.com <blmblm(a)myrealbox.com> wrote: > >> In article <i3c3o1$hqp$1(a)speranza.aioe.org>, >> Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote: >>> askaholik schrieb: >>>> Hi all, >>>> >>>> I have a program that requires interactive inputs and I want to >>>> somehow pass my inputs automatically to it. >>>> >>>> To be more clear, it looks like that >>>> $./oldProgram >>>> write a name: [the program is waiting for some input, I type "hello" >>>> and press enter] >>>> write the surname: [the program is waiting for some input, I type >>>> "foo" and press enter] >>>> etc... >>> For example... >>> >>> ./oldProgram << EOT >>> hello >>> foo >>> EOT >>> >>> or... >>> >>> echo $'hello\nfoo' | ./oldProgram >>> >>> >>> Janis >>> >>>> I want to avoid passing the values from standard input (I have to call >>>> that program hundreds times), I remember there was a trick to do it, >>>> but I cannot figure it out. Any hint would be appreciated!!! >> To the OP, and for future reference, maybe: >> >> Janis's solutions do *not* avoid the use of standard input, as >> the term is used in context. What they do is "redirect" this >> input stream, so it comes from something other than the keyboard. >> Some programs actually do read directly from the keyboard [1], >> and this kind of redirection won't work with them, but I think >> I'm safe in saying [2] that most traditional-UNIX programs read >> from standard input, and they do so in part because redirection >> is so useful! >> > > I think that is not safe, there are a considerable amount of > Unix programs which don't work with Janis' solution, especially when > dealing with passwords, for example, passwd, su, rlogin etc.. Consider; most of those programs are trying to read some user-ID and password, and, the OP wrote: "I have a program" and "./oldProgram"; which is an indication that it's most likely just using the standard channels and not /dev/tty (or a similar device); we don't know, but certainly he replied: "it is exactly what I was looking for". > expect(1) always work, and it is not hard to write a simple expect > script to solve OP's problem. Since it's so simple - it's just a few lines of code! - I suggest to provide an expect based solution if you think it's necessary for the OP's specific question. Janis > >
From: blmblm on 9 Aug 2010 15:49 In article <m3k4o1qg82.fsf(a)gmail.com>, WANG Cong <xiyou.wangcong(a)gmail.com> wrote: > On 08/04/10 20:33, blmblm(a)myrealbox.com <blmblm(a)myrealbox.com> wrote: > > > In article <i3c3o1$hqp$1(a)speranza.aioe.org>, > > Janis Papanagnou <janis_papanagnou(a)hotmail.com> wrote: > >> askaholik schrieb: [ snip ] > > To the OP, and for future reference, maybe: > > > > Janis's solutions do *not* avoid the use of standard input, as > > the term is used in context. What they do is "redirect" this > > input stream, so it comes from something other than the keyboard. > > Some programs actually do read directly from the keyboard [1], > > and this kind of redirection won't work with them, but I think > > I'm safe in saying [2] that most traditional-UNIX programs read > > from standard input, and they do so in part because redirection > > is so useful! > > > > I think that is not safe, there are a considerable amount of > Unix programs which don't work with Janis' solution, especially when > dealing with passwords, for example, passwd, su, rlogin etc.. Certainly there are exceptions, and thanks for reminding me/us of what some of them are. Just as I said in that unquoted footnote, repeated below .... Whether that really invalidates a claim about what "most" programs are like -- yeah, whatever. > expect(1) always work, and it is not hard to write a simple expect > script to solve OP's problem. For suitable values of "not hard", I suppose. I remember looking at the documentation of "expect" once and thinking "maybe I'm not *that* curious right now ...." :-)? Maybe it's an easy tool to use once you learn it, though. I'm mildly curious about why you didn't quote my footnotes >>[1] "expect" supposedly provides a way to automate input to such >>programs, but I haven't worked with it myself. >>[2] And if I'm not, someone will be along soon to explain why not. >>Sort of a :-). when you quoted so much other text, but -- yeah, whatever. -- B. L. Massingill ObDisclaimer: I don't speak for my employers; they return the favor.
First
|
Prev
|
Pages: 1 2 Prev: how to compare the first field only Next: Value of argument (just curious) |