# Interactive Commands

**URL:** <https://www.ruby-forum.com/t/interactive-commands/174227>\
**Category:** Ruby\
**Created:** [August 22, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/interactive-commands/174227 "2009-08-22T22:51:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![norwat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@norwat](https://www.ruby-forum.com/u/norwat)\
**Post date:** [August 22, 2009, 10:51pm UTC](https://www.ruby-forum.com/t/interactive-commands/174227/1 "2009-08-22T22:51:03Z")

</div>

Hey

So im trying to write an irc bot for my clan but mostly just to train  
my ruby skills a bit more.  
Anyhow some of the functions of the bot require to execute commands on  
the server itself, managed to do fine using the backticks but every now  
and then the bot just hangs because sometimes when deleting files, ie,  
the OS asks for permission and waits for user input … and it just  
hangs there waiting.  
Is there anyway to hack across this ?  
I’ve tried open3 and open4 but the also hang when i request the stdout  
of the command.  
The ideal would be to have full control of output and input via IRC :x

Thanks

---

<div class="post-metadata">

**Author:** ![norwat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@norwat](https://www.ruby-forum.com/u/norwat)\
**Post date:** [August 23, 2009, 12:15am UTC](https://www.ruby-forum.com/t/interactive-commands/174227/2 "2009-08-23T00:15:58Z")

</div>

On 22.08.2009 22:51, João Santos wrote:

> Anyhow some of the functions of the bot require to execute commands on  
> the server itself, managed to do fine using the backticks but every now  
> and then the bot just hangs because sometimes when deleting files, ie,  
> the OS asks for permission and waits for user input … and it just  
> hangs there waiting.

Why do you need an external process to delete files?

> Is there anyway to hack across this ?  
> I’ve tried open3 and open4 but the also hang when i request the stdout  
> of the command.  
> The ideal would be to have full control of output and input via IRC :x

Well, then you need one of the popen variants and need to read the  
command’s output, detect that it needs input and handle that accordingly  
(e.g. forward it to a client).

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![norwat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@norwat](https://www.ruby-forum.com/u/norwat)\
**Post date:** [August 24, 2009, 8:15am UTC](https://www.ruby-forum.com/t/interactive-commands/174227/3 "2009-08-24T08:15:46Z")

</div>

On 24.08.2009 00:34, João Santos wrote:

> > Well, then you need one of the popen variants and need to read the  
> > command’s output, detect that it needs input and handle that accordingly  
> > (e.g. forward it to a client).
> 
> Can you point me which one ? Or to some documentation on popen, i havent  
> found any decent documentation on popen3 or popen4, i’ve been following  
> examples and trial’n’error basically

Well, there’s [http://ruby-doc.org/](http://ruby-doc.org/) and when searching for “ruby popen3”  
you get this:

[http://www.google.com/search?q=ruby+popen3](http://www.google.com/search?q=ruby+popen3)

Cheers

robert

---

<div class="post-metadata">

**Author:** ![norwat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@norwat](https://www.ruby-forum.com/u/norwat)\
**Post date:** [August 24, 2009, 12:34am UTC](https://www.ruby-forum.com/t/interactive-commands/174227/4 "2009-08-24T00:34:04Z")

</div>

Robert K. wrote:

> On 22.08.2009 22:51, Joï¿½o Santos wrote:
> 
> > Anyhow some of the functions of the bot require to execute commands on  
> > the server itself, managed to do fine using the backticks but every now  
> > and then the bot just hangs because sometimes when deleting files, ie,  
> > the OS asks for permission and waits for user input … and it just  
> > hangs there waiting.
> 
> Why do you need an external process to delete files?

Its just an example, what i want is to execute system commands even  
those who wait for user input. Doesnt really matter if it is over IRC i  
cant run a command under ruby which requires input without making the  
whole script hang.

> Well, then you need one of the popen variants and need to read the  
> command’s output, detect that it needs input and handle that accordingly  
> (e.g. forward it to a client).
> 
> Kind regards
> 
> robert

Can you point me which one ? Or to some documentation on popen, i havent  
found any decent documentation on popen3 or popen4, i’ve been following  
examples and trial’n’error basically
