I am trying to write a wrapper for a program with an interactive shell,
under windows. I am having problems with the process blocking
permanently or repeating the last command. When it is like the following
it loops forever on the puts.
IO.popen(“myprogram.exe”,“w+”) do |link|
link.puts "command"
link.close_write
result = link.readlines
p result
end
When I remove the close_write it doesn’t loop but blocks on readlines. I
can modify both the interactive program and the ruby wrapper library. I
tried explicitly putting a _flushall(); call and even a _fcloseall( );
in the interactive program but neither had any effect. How should this
be done? Any advice or examples would be great.
Edward
Hi,
At Mon, 29 Mar 2004 16:11:28 +0900,
Edward Middleton wrote in [ruby-talk:96019]:
When I remove the close_write it doesn’t loop but blocks on readlines. I
can modify both the interactive program and the ruby wrapper library. I
tried explicitly putting a _flushall(); call and even a _fcloseall( );
in the interactive program but neither had any effect. How should this
be done? Any advice or examples would be great.
At close_write, your myprogram.exe reaches EOF. You have to
check it.
···
–
Nobu Nakada
Edward Middleton wrote:
I am trying to write a wrapper for a program with an interactive shell,
You might want to look at rexpect.rb or expect.rb. I think expect.rb is
distributed with Ruby, rexpect.rb is available on rubyforge.
Ben
Ben Giddings wrote:
Edward Middleton wrote:
I am trying to write a wrapper for a program with an interactive
shell,
You might want to look at rexpect.rb or expect.rb. I think expect.rb
is distributed with Ruby, rexpect.rb is available on rubyforge.
I thought of that but It is not apear to be included with the windows
version I have installed. Is there a windows version with expect support?
Edward
Hi,
At Tue, 30 Mar 2004 09:51:38 +0900,
Edward Middleton wrote in [ruby-talk:96087]:
I am trying to write a wrapper for a program with an interactive
shell,
You might want to look at rexpect.rb or expect.rb. I think expect.rb
is distributed with Ruby, rexpect.rb is available on rubyforge.
I thought of that but It is not apear to be included with the windows
version I have installed. Is there a windows version with expect support?
Windows doesn’t pty support. I’d like to know how to create
pseudo console on Windows, if it were possible.
···
–
Nobu Nakada
I think this is how to do it.
Edward
···
nobu.nokada@softhome.net wrote:
Hi,
At Tue, 30 Mar 2004 09:51:38 +0900, Edward Middleton wrote in
[ruby-talk:96087]:
I am trying to write a wrapper for a program with an interactive
shell, | | | You might want to look at rexpect.rb or expect.rb.
I think expect.rb | is distributed with Ruby, rexpect.rb is
available on rubyforge.
I thought of that but It is not apear to be included with the
windows version I have installed. Is there a windows version with
expect support?
Windows doesn’t pty support. I’d like to know how to create pseudo
console on Windows, if it were possible.
Hi,
At Tue, 30 Mar 2004 15:09:15 +0900,
Edward Middleton wrote in [ruby-talk:96102]:
I am trying to write a wrapper for a program with an interactive
shell, | | | You might want to look at rexpect.rb or expect.rb.
I think expect.rb | is distributed with Ruby, rexpect.rb is
available on rubyforge.
I thought of that but It is not apear to be included with the
windows version I have installed. Is there a windows version with
expect support?
Windows doesn’t pty support. I’d like to know how to create pseudo
console on Windows, if it were possible.
I think this is how to do it.
Microsoft Learn: Build skills that open doors in your career
I didn’t mean how to use console, but how to provide console
features to subprocess from a process.
···
–
Nobu Nakada
I am not sure I am understanding but would this be what you are refering
to. It allows you to create a new process in a new console or inherit
the parents console.
It is also possiable to associate a console with a graphical application
using
Edward Middleton
···
nobu.nokada@softhome.net wrote:
I think this is how to do it.
Microsoft Learn: Build skills that open doors in your career
I didn’t mean how to use console, but how to provide console
features to subprocess from a process.
Hi,
At Wed, 31 Mar 2004 17:24:59 +0900,
Edward Middleton wrote in [ruby-talk:96204]:
[1 <text/plain; ISO-8859-1 (7bit)>]
I am not sure I am understanding but would this be what you are refering
to. It allows you to create a new process in a new console or inherit
the parents console.
Default console provided by Windows quite differs from pty.
BTW, your original issue seems not to be concerned with pty at
all. Have you read [ruby-talk:96023]?
···
nobu.nokada@softhome.net wrote:
–
Nobu Nakada
I have read it but probably not understood. I realize it should not
have a close_write because I intend to continue using the processes
stdin. The program does not terminate after processing the first
command. Isn’t EOF only issued when the program terminates and closes
its stdout?
Edward Middleton
···
nobu.nokada@softhome.net wrote:
Default console provided by Windows quite differs from pty.
BTW, your original issue seems not to be concerned with pty at all.
Have you read [ruby-talk:96023]?
nobu.nokada@softhome.net wrote:
At close_write, your myprogram.exe reaches EOF. You have to check
it.