From: Daniel Flores on
i have been trying to recieved the output of a command with IO.popen and
it works great but if i place a unknown command to the system the ruby
program terminates.

def comando ( inputcmd )
f = IO.popen(inputcmd)
output = f.readlines
return output
end


#########################################################
there is a loop calling the method like this:
#########################################################


cliente.puts "Escriba el comando a ejecutar por cmd.exe: "
inputcmd = cliente.gets
cliente.puts comando( inputcmd )


any help will be appreciated!!

Thank you!
--
Posted via http://www.ruby-forum.com/.

From: Daniel Flores on
i found the solution on the forum :D

i use: IO.popen(cmdline + " 2>&1", "w+")

but now i have another problem, if i run a command that needs several
lines
the output comes back incomplete.
Any ideas?

there is a way to increase the size of the
buffer? does it affect if the variable its been trransfer with
TCPSockets??
--
Posted via http://www.ruby-forum.com/.

From: Roger Pack on
Daniel Flores wrote:
> i found the solution on the forum :D
>
> i use: IO.popen(cmdline + " 2>&1", "w+")
>
> but now i have another problem, if i run a command that needs several
> lines
> the output comes back incomplete.
> Any ideas?

use .read instead of .gets (?)

-r
--
Posted via http://www.ruby-forum.com/.