From: Daniel Flores on 26 Jul 2010 23:17 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 26 Jul 2010 23:41 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 27 Jul 2010 07:59 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/.
|
Pages: 1 Prev: How to proceed? Next: Beginner help needed: use a class def to create new instance |