Ok, so may be I should explain this with some example code ( here irb is
choosen only for demonstration):

    check = IO.popen("ruby c:/ruby/bin/irb.rb",'r+')
    check.puts("s = 'abcd'")
    check.puts("puts 'matched' if  s=~/a|b|c|d/")
    check.puts("puts $:")
    check.puts("puts $\"")
    check.close_write
    check.readlines.each { |line| puts line.upcase unless line =~ 'nil' }

which on my machine (ruby 1.7.3 (2002-11-17) [i386-mswin32]) produces:

    irb(main):001:0> s = 'abcd'
     "abcd"
    irb(main):002:0> puts 'matched' if  s=~/a|b|c|d/
     matched
    irb(main):003:0> puts $:
     C:/ruby/lib/ruby/site_ruby/1.7
     C:/ruby/lib/ruby/site_ruby/1.7/i386-msvcrt
     C:/ruby/lib/ruby/site_ruby
     C:/ruby/lib/ruby/1.7
     C:/ruby/lib/ruby/1.7/i386-mswin32
     .
    irb(main):004:0> puts $"
     irb.rb
     e2mmap.rb
     irb/init.rb
     irb/context.rb
     irb/workspace.rb
     irb/extend-command.rb
     irb/ruby-lex.rb
     irb/slex.rb
     irb/ruby-token.rb
     irb/input-method.rb
     irb/locale.rb
     tempfile.rb
     delegate.rb
    irb(main):005:0> exit

Notice that I have to club all the "check.puts" functions before the
"check.close_write" and then do readlines

Is there a way to check.puts each command and then immediately read the
lines of output ?
I think IO#popen3 might do this, but it is not available on Windows.

TIA,

-- shanko


"Shashank Date" <sdate / kc.rr.com> wrote in message
news:e90M9.26673$_b.451371 / twister.kc.rr.com...
> I am trying to automate an interactive DOS command line utility (something
> like irb)
> using ruby 1.7.3 (on Windows 2000).
>
> I tried using IO#popen but could not make the inputs (puts) interlace with
> outputs (gets).
> I had to batch all the puts's together before doing the gets.
>
> Any suggestions ?
>
> TIA,
> -- shanko
>
>