Interacting with other programs

J

Jeppe Jakobsen

Is it possible to make some kind of program hook in ruby, so I can have
the program in question send it's calls to my ruby script first, and
then have ruby forward them to the program?

If so, please throw me a link where I can read on the subject. Tried to
look into some win32API docs, but didn´t find what I was looking for.

Thanks in advance.
 
R

Robert Klemme

2010/8/24 Jeppe Jakobsen said:
Is it possible to make some kind of program hook in ruby, so I can have
the program in question send it's calls to my ruby script first, and
then have ruby forward them to the program?

If so, please throw me a link where I can read on the subject. Tried to
look into some win32API docs, but didn=B4t find what I was looking for.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/66884

You can also use #expect from the standard lib:

require 'expect'

IO.popen "your command", "r+" do |io|
prompt_seen =3D false

io.expect ">", 100 do |line|
prompt_seen =3D true
printf "Got prompt: %p\n", line
end

puts "no prompt in time!" unless prompt_seen

io.puts "exit" # for shells and other interactive programs
io.close_write
end

The code is untested but should get you going into the right direction.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top