How to implement Expect's interact in Ruby?

I’m writing a program, which is supposed to to the following>

  • log into a foreign host using ssh, then,
  • set up various stuff (environment variables etc.), then
  • invoke an interactive command line tool on this host, then
  • pass a few commands to this tool, and finally
  • hand over the control to the user, so that he can continue interacting
    with this program

I can do everything using the modules pty and expect, except the last
item. If I would write this in Tcl/Expect, I would simply invoke the


program. In Perl (using the Expect module), I would write


(where $exp is my Expect object). How can I do this in Ruby?