# Running shell scripts

**URL:** <https://rubytalk.org/t/running-shell-scripts/40925>\
**Category:** ruby-talk\
**Created:** [26 September 2007 01:15 UTC](https://rubytalk.org/t/running-shell-scripts/40925 "2007-09-26T01:15:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggie5](https://avatars.discourse-cdn.com/v4/letter/e/7c8e57/32.png) [@eggie5](https://rubytalk.org/u/eggie5)\
**Post date:** [26 September 2007 01:15 UTC](https://rubytalk.org/t/running-shell-scripts/40925/1 "2007-09-26T01:15:03Z")

</div>

How can I run this command from my ruby script?

/usr/bin/java -jar #{jsmin\_path}/custom\_rhino.jar -c  
#{tmp\_path}\_uncompressed.js

---

<div class="post-metadata">

**Author:** ![Tim\_Hunter4](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@Tim\_Hunter4](https://rubytalk.org/u/Tim_Hunter4)\
**Post date:** [26 September 2007 01:19 UTC](https://rubytalk.org/t/running-shell-scripts/40925/2 "2007-09-26T01:19:58Z")

</div>

veggie5 wrote:

> How can I run this command from my ruby script?
> 
> /usr/bin/java -jar #{jsmin\_path}/custom\_rhino.jar -c  
> #{tmp\_path}\_uncompressed.js

ri Kernel#system

> **···**
>
> --  
> RMagick OS X Installer [[http://rubyforge.org/projects/rmagick/\](http://rubyforge.org/projects/rmagick/%5C)]  
> RMagick Hints & Tips [[http://rubyforge.org/forum/forum.php?forum\_id=1618\](http://rubyforge.org/forum/forum.php?forum_id=1618%5C)]  
> RMagick Installation FAQ [[http://rmagick.rubyforge.org/install-faq.html\](http://rmagick.rubyforge.org/install-faq.html%5C)]

---

<div class="post-metadata">

**Author:** ![Unbewusst\_Sein2](https://avatars.discourse-cdn.com/v4/letter/u/91b2a8/32.png) [@Unbewusst\_Sein2](https://rubytalk.org/u/Unbewusst_Sein2)\
**Post date:** [26 September 2007 02:00 UTC](https://rubytalk.org/t/running-shell-scripts/40925/3 "2007-09-26T02:00:04Z")

</div>

---------------------------------------------------------- Kernel#system  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system(cmd [, arg, ...]) =\> true or false

> **···**
>
> Tim Hunter \<TimHunter@nc.rr.com\> wrote:
> 
> > veggie5 wrote:  
> > \> How can I run this command from my ruby script?  
> > \>  
> > \> /usr/bin/java -jar #{jsmin\_path}/custom\_rhino.jar -c  
> > \> #{tmp\_path}\_uncompressed.js  
> > \>  
> > \>
> > 
> > ri Kernel#system
> 
> ------------------------------------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Executes \_cmd\_ in a subshell, returning +true+ if the command was  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found and ran successfully, +false+ otherwise. An error status is  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;available in +$?+. The arguments are processed in the same way as  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for +Kernel::exec+.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system("echo \*")  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system("echo", "\*")
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\_produces:\_
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;config.h main.rb  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\*
> 
> (END)  
> --  
> Une Bévue

---

<div class="post-metadata">

**Author:** ![Unbewusst\_Sein2](https://avatars.discourse-cdn.com/v4/letter/u/91b2a8/32.png) [@Unbewusst\_Sein2](https://rubytalk.org/u/Unbewusst_Sein2)\
**Post date:** [26 September 2007 02:00 UTC](https://rubytalk.org/t/running-shell-scripts/40925/4 "2007-09-26T02:00:06Z")

</div>

better (on mac os x) :

ri Kernel\#system

> **···**
>
> Une Bévue \<unbewusst.sein@weltanschauung.com.invalid\> wrote:
> 
> > \> ri Kernel#system
> 
> --  
> Une Bévue

---

<div class="post-metadata">

**Author:** ![eggie5](https://avatars.discourse-cdn.com/v4/letter/e/7c8e57/32.png) [@eggie5](https://rubytalk.org/u/eggie5)\
**Post date:** [26 September 2007 02:05 UTC](https://rubytalk.org/t/running-shell-scripts/40925/5 "2007-09-26T02:05:03Z")

</div>

thanks

> **···**
>
> On Sep 25, 6:59 pm, unbewusst.s...@weltanschauung.com.invalid (Une Bévue) wrote:
> 
> > Une Bévue \<unbewusst.s...@weltanschauung.com.invalid\> wrote:  
> > \> \> ri Kernel#system
> > 
> > better (on mac os x) :
> > 
> > ri Kernel\#system
> > 
> > --  
> > Une Bévue

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [26 September 2007 02:59 UTC](https://rubytalk.org/t/running-shell-scripts/40925/6 "2007-09-26T02:59:18Z")

</div>

The first version works fine on my OS X box:

Welcome to Darwin!  
Firefly:~$ ri -T Kernel#system  
---------------------------------------------------------- Kernel#system  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system(cmd [, arg, ...]) =\> true or false

> **···**
>
> On Sep 25, 2007, at 9:00 PM, Une Bévue wrote:
> 
> > Une Bévue \<unbewusst.sein@weltanschauung.com.invalid\> wrote:
> > 
> > > > ri Kernel#system
> > 
> > better (on mac os x) :
> > 
> > ri Kernel\#system
> 
> ------------------------------------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Executes \_cmd\_ in a subshell, returning +true+ if the command was  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found and ran successfully, +false+ otherwise. An error status is  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;available in +$?+. The arguments are processed in the same way as  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for +Kernel::exec+.
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system("echo \*")  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system("echo", "\*")
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\_produces:\_
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;config.h main.rb  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\*
> 
> James Edward Gray II

---

<div class="post-metadata">

**Author:** ![Terry\_Poulin](https://avatars.discourse-cdn.com/v4/letter/t/ccd318/32.png) [@Terry\_Poulin](https://rubytalk.org/u/Terry_Poulin)\
**Post date:** [26 September 2007 21:59 UTC](https://rubytalk.org/t/running-shell-scripts/40925/7 "2007-09-26T21:59:27Z")

</div>

Une Bévue wrote:

> **···**
>
> > Une Bévue \<unbewusst.sein@weltanschauung.com.invalid\> wrote:
> > 
> > > \> ri Kernel#system
> > 
> > better (on mac os x) :
> > 
> > ri Kernel\#system
> > 
> > --  
> > Une Bévue
> 
> ri Kernel.system or enclosing the arguments to ri in '' should work on most  
> systems too 🙂
> 
> TerryP.
> 
> --  
> &nbsp;&nbsp;&nbsp;&nbsp;  
> Email and shopping with the feelgood factor!  
> 55% of income to good causes. [http://www.ippimail.com](http://www.ippimail.com)

---

<div class="post-metadata">

**Author:** ![Unbewusst\_Sein2](https://avatars.discourse-cdn.com/v4/letter/u/91b2a8/32.png) [@Unbewusst\_Sein2](https://rubytalk.org/u/Unbewusst_Sein2)\
**Post date:** [26 September 2007 04:00 UTC](https://rubytalk.org/t/running-shell-scripts/40925/8 "2007-09-26T04:00:27Z")

</div>

here is my output :

~%\> ri Kernel#system  
zsh: no matches found: Kernel#system

i'm using zsh as shell script, may u aren't using it, this could be the  
reason, because it's zsh interpreting the command line and which found  
something wrong, the reason for my escaping #....

otherwise i'm using :

~%\> which ruby  
/opt/local/bin/ruby  
~%\> /opt/local/bin/ruby --version  
ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.9.0]  
~%\>

over MacOS X 10.4.10 running in a PPC iMac.

and also :

~%\> zsh --version  
zsh 4.3.2 (powerpc-apple-darwin8.8.0)

> **···**
>
> James Edward Gray II \<james@grayproductions.net\> wrote:
> 
> > The first version works fine on my OS X box:
> 
> --  
> Une Bévue
