# Running command line scripts from Rails

**URL:** <https://www.ruby-forum.com/t/running-command-line-scripts-from-rails/143894>\
**Category:** Rails\
**Created:** [July 23, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/running-command-line-scripts-from-rails/143894 "2008-07-23T17:00:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [July 23, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/running-command-line-scripts-from-rails/143894/1 "2008-07-23T17:00:43Z")

</div>

Hi

I have an application that makes use of some tools that are provided on  
the installed system. (statistical model compilation).

How should I do this gracefully w/ Rails.

In the past (Java equivalent) I have relied on either an API being  
provided OR scraping the results of System.exec (I guess the Ruby  
equivalent is Runtime.exec)… not sure how to do this in Rails though.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [July 23, 2008, 11:47pm UTC](https://www.ruby-forum.com/t/running-command-line-scripts-from-rails/143894/2 "2008-07-23T23:47:50Z")

</div>

There are two ways I know of. To run a simple command like ls -l:

system ‘ls -l’

%x{ls -l}

There are subtle differences between the two, but see which works for  
you.

On Jul 23, 11:00 am, Jean N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jeannibee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@jeannibee](https://www.ruby-forum.com/u/jeannibee)\
**Post date:** [July 24, 2008, 5:52am UTC](https://www.ruby-forum.com/t/running-command-line-scripts-from-rails/143894/3 "2008-07-24T05:52:46Z")

</div>

Brian A. wrote:

> There are two ways I know of. To run a simple command like ls -l:
> 
> system ‘ls -l’
> 
> %x{ls -l}
> 
> There are subtle differences between the two, but see which works for  
> you.
> 
> On Jul 23, 11:00ï¿½am, Jean N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks I’ll do some reading on it this weekend and post some results.

Appreciate the reply.
