Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2532
| From | Brian Candler <b.candler@pobox.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: reading and writing to child process with streams in ruby |
| Date | 2011-04-08 08:32 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <25ff3d42fe12472e3f3c8ea44c2dbc19@ruby-forum.com> (permalink) |
| References | <09ce70f0-118a-4e4d-82f1-7d88436233ff@l39g2000yqh.googlegroups.com> |
mpurdy wrote in post #991644: > echo -n "username: " You are sending just "username: " without a trailing newline. > line = stdout.read Here you are reading from stdout until the end-of-file (i.e. until the other side terminates or closes the file). This will wait forever. Two possible solutions: 1. Change your shell script to send data ending with a newline, then use 'gets' in the ruby code. 2. More generally, use expect.rb in the standard library. Then you can wait for a particular sequence of characters, e.g. /name: /, before continuing. HTH, Brian. -- Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
reading and writing to child process with streams in ruby mpurdy <mpurdy1973usergroups@gmail.com> - 2011-04-07 20:58 -0700
Re: reading and writing to child process with streams in ruby "Y. NOBUOKA" <nobuoka@r-definition.com> - 2011-04-08 03:03 -0500
Re: reading and writing to child process with streams in ruby mpurdy <mpurdy1973usergroups@gmail.com> - 2011-04-08 18:44 -0700
Re: reading and writing to child process with streams in ruby Brian Candler <b.candler@pobox.com> - 2011-04-08 08:32 -0500
Re: reading and writing to child process with streams in ruby mpurdy <mpurdy1973usergroups@gmail.com> - 2011-04-08 18:48 -0700
csiph-web