# Shell program

**URL:** <https://www.ruby-forum.com/t/shell-program/95060>\
**Category:** Ruby\
**Created:** [December 4, 2005, 1:02pm UTC](https://www.ruby-forum.com/t/shell-program/95060 "2005-12-04T13:02:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sky.yin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@sky.yin](https://www.ruby-forum.com/u/sky.yin)\
**Post date:** [December 4, 2005, 1:02pm UTC](https://www.ruby-forum.com/t/shell-program/95060/1 "2005-12-04T13:02:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sky.yin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@sky.yin](https://www.ruby-forum.com/u/sky.yin)\
**Post date:** [December 4, 2005, 1:51pm UTC](https://www.ruby-forum.com/t/shell-program/95060/2 "2005-12-04T13:51:23Z")

</div>

From: “Sky Y.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 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

---

<div class="post-metadata">

**Author:** ![sky.yin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@sky.yin](https://www.ruby-forum.com/u/sky.yin)\
**Post date:** [December 4, 2005, 2:07pm UTC](https://www.ruby-forum.com/t/shell-program/95060/3 "2005-12-04T14:07:38Z")

</div>

Thanks, Bill.

The yet another ruby shortcut works.
