# Reading result of a command

**URL:** <https://www.ruby-forum.com/t/reading-result-of-a-command/161895>\
**Category:** Ruby\
**Created:** [March 3, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/reading-result-of-a-command/161895 "2009-03-03T15:06:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![indium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/35a633/32.png) [@indium](https://www.ruby-forum.com/u/indium)\
**Post date:** [March 3, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/reading-result-of-a-command/161895/1 "2009-03-03T15:06:15Z")

</div>

Hi All,

I am using system(“dir”) to execute commands in Command Prompt.

I get the result(below) when I execute system(“dir”) command. I need to  
store the result in an array.  
I tried arr = system(“dir”) which stores true or false. Please throw  
some light on this

# Result:

Volume in drive E has no label.  
Volume Serial Number is 603F-F8C6

Directory of E:\Temp

# 02/27/2009 07:05 PM . 02/27/2009 07:05 PM … 03/03/2009 07:11 PM 65 t.rb 02/27/2009 06:22 PM 3,251 temp.rb 02/27/2009 07:05 PM 1,011 temp2.rb 3 File(s) 4,327 bytes 2 Dir(s) 22,208,159,744 bytes free

Thanks,  
Venkat

---

<div class="post-metadata">

**Author:** ![indium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/35a633/32.png) [@indium](https://www.ruby-forum.com/u/indium)\
**Post date:** [March 3, 2009, 3:12pm UTC](https://www.ruby-forum.com/t/reading-result-of-a-command/161895/2 "2009-03-03T15:12:32Z")

</div>

Venkat K. wrote:

> I am using system(“dir”) to execute commands in Command Prompt.
> 
> I get the result(below) when I execute system(“dir”) command. I need to  
> store the result in an array.

Use one of the forms of backticks:

result = `dir`  
result = %x{dir}

or use IO.popen.
