Force IRB into interactive mode (to display prompt)?

R

Rob Pierry

I'm implementing a front end for irb that involves running it in a
background process. I have it working such that I can collect input
from my program and write it to the redirected stdin of irb and then
read the output from redirected stdout, but it looks like when irb
detects that it isn't running in interactive mode it doesn't print a
prompt for some reason.

I've tried setting conf.verbose = true, but that doesn't work. If I
don't redirect stdin, the prompt appears just fine. How can I force irb
to display the prompt, even if stdin is redirected?

I'm using 1.8.5 on windows xp.
 
J

John Joyce

I'm implementing a front end for irb that involves running it in a
background process. I have it working such that I can collect input
from my program and write it to the redirected stdin of irb and then
read the output from redirected stdout, but it looks like when irb
detects that it isn't running in interactive mode it doesn't print a
prompt for some reason.

I've tried setting conf.verbose = true, but that doesn't work. If I
don't redirect stdin, the prompt appears just fine. How can I
force irb
to display the prompt, even if stdin is redirected?

I'm using 1.8.5 on windows xp.
What are you trying to do?
You want some kind of status program to monitor activity?
 
R

Rob Pierry

John said:
What are you trying to do?
You want some kind of status program to monitor activity?

I want to have a pane in my GUI that works like irb. Basically embed it
into a windows app. I'm starting a process in the background for irb
and I want to pass input to it and read output from it. It's
interactive, it's just indirectly interactive so irb doesn't print the
prompt and dies immediately on error instead of printing the message and
staying alive.
 
P

Pit Capitain

2007/10/4 said:
I want to have a pane in my GUI that works like irb. Basically embed it
into a windows app. I'm starting a process in the background for irb
and I want to pass input to it and read output from it. It's
interactive, it's just indirectly interactive so irb doesn't print the
prompt and dies immediately on error instead of printing the message and
staying alive.

Rob, you could look at fxri (http://rubyforge.org/projects/fxri) how
they do it. It's a part of the one-click-installer.

Regards,
Pit
 
R

Rob Pierry

Pit said:
Rob, you could look at fxri (http://rubyforge.org/projects/fxri) how
they do it. It's a part of the one-click-installer.

Regards,
Pit

I've looked at fxri and its UI is launched from the same ruby process
that is already running, so it can manipulate the IRB class directly.
FXRI has its own custom IRB Inputmethod and manages the printing of the
prompt itself. For various reasons I need to start the ruby process
separately from my main app (which isn't in ruby). I could probably
write some ruby code that I executed instead of just running IRB that
managed the input and prompting, but I was hoping there was an easier
way that just involved setting some flags for IRB or something so it
behaved like it was in interactive mode.

Thanks.
 
R

Rob Pierry

Rob said:
I'm implementing a front end for irb that involves running it in a
background process. I have it working such that I can collect input
from my program and write it to the redirected stdin of irb and then
read the output from redirected stdout, but it looks like when irb
detects that it isn't running in interactive mode it doesn't print a
prompt for some reason.

I've tried setting conf.verbose = true, but that doesn't work. If I
don't redirect stdin, the prompt appears just fine. How can I force irb
to display the prompt, even if stdin is redirected?

I'm using 1.8.5 on windows xp.

May have solved my own problem.

It looks like passing:
--readline --prompt default

to irb makes things work. When I start irb normally, I end up with
readline for input and the prompt. When my app was starting the
process, I ended up with the stdio input and no prompt.

Thanks for all the replies.
 

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,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top