[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Force IRB into interactive mode (to display prompt)?

Rob Pierry

10/4/2007 2:32:00 PM

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.
--
Posted via http://www.ruby-....

5 Answers

John Joyce

10/4/2007 3:59:00 PM

0


On Oct 4, 2007, at 9:31 AM, Rob Pierry 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.
> --
> Posted via http://www.ruby-....
>
What are you trying to do?
You want some kind of status program to monitor activity?


Rob Pierry

10/4/2007 4:03:00 PM

0

John Joyce wrote:
> On Oct 4, 2007, at 9:31 AM, Rob Pierry wrote:
>
>> to display the prompt, even if stdin is redirected?
>>
>> I'm using 1.8.5 on windows xp.
>> --
>> Posted via http://www.ruby-....
>>
> 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.

--
Posted via http://www.ruby-....

Pit Capitain

10/5/2007 9:59:00 AM

0

2007/10/4, Rob Pierry <rpierry+ruby@gmail.com>:
> 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/pro...) how
they do it. It's a part of the one-click-installer.

Regards,
Pit

Rob Pierry

10/5/2007 2:05:00 PM

0

Pit Capitain wrote:
> 2007/10/4, Rob Pierry <rpierry+ruby@gmail.com>:
>> 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/pro...) 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.
--
Posted via http://www.ruby-....

Rob Pierry

10/5/2007 4:17:00 PM

0

Rob Pierry 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.
--
Posted via http://www.ruby-....