# Ruby's %x{} -- running system commands

**URL:** <https://www.ruby-forum.com/t/rubys-x-running-system-commands/187829>\
**Category:** Ruby\
**Created:** [April 30, 2010, 1:18am UTC](https://www.ruby-forum.com/t/rubys-x-running-system-commands/187829 "2010-04-30T01:18:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [April 30, 2010, 1:18am UTC](https://www.ruby-forum.com/t/rubys-x-running-system-commands/187829/1 "2010-04-30T01:18:58Z")

</div>

The command I execute within %x{…}, if executed on the command line,  
works perfectly, every time.

If I run the same command within Ruby’s %x{…}, I get mixed results.  
Sometimes a blank string, other times the expected output.

Why?

---

<div class="post-metadata">

**Author:** ![dewie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@dewie](https://www.ruby-forum.com/u/dewie)\
**Post date:** [April 30, 2010, 2:20am UTC](https://www.ruby-forum.com/t/rubys-x-running-system-commands/187829/2 "2010-04-30T02:20:00Z")

</div>

On Apr 29, 2010, at 16:19 , Daniel W. wrote:

> The command I execute within %x{…}, if executed on the command line,  
> works perfectly, every time.
> 
> If I run the same command within Ruby’s %x{…}, I get mixed results.  
> Sometimes a blank string, other times the expected output.
> 
> Why?

We can’t possibly answer that without more information. Provide us  
enough information that we might be able to see the problem.
