# Force IRB into interactive mode (to display prompt)?

**URL:** <https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337>\
**Category:** Ruby\
**Created:** [October 4, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337 "2007-10-04T16:31:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 4, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/1 "2007-10-04T16:31:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 4, 2007, 5:59pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/2 "2007-10-04T17:59:59Z")

</div>

On Oct 4, 2007, at 9:31 AM, Rob P. wrote:

> to display the prompt, even if stdin is redirected?
> 
> ## I’m using 1.8.5 on windows xp.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

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

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 4, 2007, 6:02pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/3 "2007-10-04T18:02:31Z")

</div>

John J. wrote:

> On Oct 4, 2007, at 9:31 AM, Rob P. wrote:
> 
> > to display the prompt, even if stdin is redirected?
> > 
> > ## I’m using 1.8.5 on windows xp.
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> 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.

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 5, 2007, 11:59am UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/4 "2007-10-05T11:59:19Z")

</div>

2007/10/4, Rob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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](http://rubyforge.org/projects/fxri)) how  
they do it. It’s a part of the one-click-installer.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 5, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/5 "2007-10-05T18:17:12Z")

</div>

Rob P. wrote:

> 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.

---

<div class="post-metadata">

**Author:** ![rpierry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@rpierry](https://www.ruby-forum.com/u/rpierry)\
**Post date:** [October 5, 2007, 4:04pm UTC](https://www.ruby-forum.com/t/force-irb-into-interactive-mode-to-display-prompt/116337/6 "2007-10-05T16:04:33Z")

</div>

Pit C. wrote:

> 2007/10/4, Rob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > 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](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.
