Interactive Commands

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

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

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/ and when searching for “ruby popen3”
you get this:

http://www.google.com/search?q=ruby+popen3

Cheers

robert

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