Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ruby Programming Language

How to capture the output of system("")?


All,

When I can system("...") in ruby, I got either true or false returned,
but how do I capture the information that being printed out in console
when the cmd is being executed?

Thanks

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

Yingqi Tang wrote:
> When I can system("...") in ruby, I got either true or false returned,
> but how do I capture the information that being printed out in console
> when the cmd is being executed?

By using backticks or %x{} instead of system.

--
Ist so, weil ist so
Bleibt so, weil war so

On Jun 4, 10:47 am, Sebastian Hungerecker <sep@googlemail.com>
wrote:

> Yingqi Tang wrote:
> > When I can system("...") in ruby, I got either true or false returned,
> > but how do I capture the information that being printed out in console
> > when the cmd is being executed?

> By using backticks or %x{} instead of system.

> --
> Ist so, weil ist so
> Bleibt so, weil war so

Another option besides backticks or %x{} is to use IO#popen.  This is
useful if you want to read output in the same manner as you would with
a file.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc