I'm using Expect inside of a ruby script to control an external
program. So far I have only used libexpect from a C program and would
have several questions regarding the Ruby interface of Expect, maybe
I didn't know there was one yet.
I wrote this a while[!] back:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/66218
I usually end up using Tcl to do this now, it seems to be less pain in
the end, but you may find this
http://marc.info/?l=ruby-talk&m=104759066322769&w=2
and for more normal usage of PTY + expect.rb (which can't handle multiple
patterns, IIRC)
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-02/msg01431.html
or
http://www.koders.com/ruby/fid31E61088C10EBB90329CB14D4306D52041F1F54F.aspx?s=thread
which can be found with a shorter URL
https://www.codeblog.org/viewsrc/ruby-1.8.3/ext/pty/expect_sample.rb
I'd love to see something better in this area. I think it would be nice
if libexpect were re-invented for ruby, so it doesn't have the Tcl taste
when you use it. Each flavour is OK on its own, but like fish and custard,
you don't really want them together.
someone already experienced using it:
After having processed the output of the external program that I'm
interested in I would like to empty the expect buffer by expecting an
EOF marker. In an expect script this can be done by "expect eof
{ doSomething }". Does anyone know how this can be done in Ruby?
How can I know whether the external program has already finished?
How to handle several different cases inside of an expect statement:
expect {
timeout { doAction1 }
eof { doAction2 }
...
}
In the meantime, could you drive a pure expect script with popen,
having expect_user and send_user talk to the ruby side of things?
If you have expect there already, this overburden the dependency graph
of the program, will it? And if you know how to get this working in
expect itself....
Is there any documentation for the ruby interface?
I would also be very grateful for partial answers and/or any related
information.
Thanks in advance,
Stephan
Hugh
···
On Fri, 31 Oct 2008, stephan.zimmer wrote: