# Shell program

**URL:** <https://rubytalk.org/t/shell-program/22985>\
**Category:** ruby-talk\
**Created:** [4 December 2005 07:06 UTC](https://rubytalk.org/t/shell-program/22985 "2005-12-04T07:06:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sky\_Yin](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@Sky\_Yin](https://rubytalk.org/u/Sky_Yin)\
**Post date:** [4 December 2005 07:06 UTC](https://rubytalk.org/t/shell-program/22985/1 "2005-12-04T07:06:13Z")

</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:** ![Bill\_Kelly](https://avatars.discourse-cdn.com/v4/letter/b/cc9497/32.png) [@Bill\_Kelly](https://rubytalk.org/u/Bill_Kelly)\
**Post date:** [4 December 2005 07:20 UTC](https://rubytalk.org/t/shell-program/22985/2 "2005-12-04T07:20:26Z")

</div>

> 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

> **···**
>
> From: "Sky Yin" \<sky.yin@gmail.com\>

---

<div class="post-metadata">

**Author:** ![Sky\_Yin](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@Sky\_Yin](https://rubytalk.org/u/Sky_Yin)\
**Post date:** [4 December 2005 07:31 UTC](https://rubytalk.org/t/shell-program/22985/3 "2005-12-04T07:31:32Z")

</div>

Thanks, Bill.

The yet another ruby shortcut works.

> **···**
>
> On 12/4/05, Bill Kelly \<billk@cts.com\> wrote:
> 
> > 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
