Forum: Ruby Shell program

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cee38055ae36590c654c04c2d5cc2778?d=identicon&s=25 sky.yin (Guest)
on 2005-12-04 13:02
(Received via mailing list)
Hi, rubyists

I'm using system() to execute a shell program under Windows. I wonder
how I can get the result of the external program as a string, since
the system() returns either true or false. I also try to use the Dos
pipeline to save the result to a file, but it doesn't work like this:
system(" program.exe >result.txt"). I can't find anything to explain
why in ruby document. Anyone can help me a bit?

Thanks,

Sky
4feed660d3728526797edeb4f0467384?d=identicon&s=25 billk (Guest)
on 2005-12-04 13:51
(Received via mailing list)
From: "Sky Yin" <sky.yin@gmail.com>
>
> I'm using system() to execute a shell program under Windows. I wonder
> how I can get the result of the external program as a string, since
> the system() returns either true or false.

string = `program.exe`


(See also: IO.popen for another way.)


Hope this helps,

Bill
Cee38055ae36590c654c04c2d5cc2778?d=identicon&s=25 sky.yin (Guest)
on 2005-12-04 14:07
(Received via mailing list)
Thanks, Bill.

The yet another ruby shortcut works.
This topic is locked and can not be replied to.