[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Yingqi Tang

6/4/2007 5:37:00 PM

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-....

2 Answers

Sebastian Hungerecker

6/4/2007 5:47:00 PM

0

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

james.d.masters

6/4/2007 7:26:00 PM

0

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.