# System commands

**URL:** <https://www.ruby-forum.com/t/system-commands/109568>\
**Category:** Ruby\
**Created:** [July 16, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/system-commands/109568 "2007-07-16T23:17:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [July 16, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/system-commands/109568/1 "2007-07-16T23:17:18Z")

</div>

Let me first apologize I asked this question last week  
and lost the answer. How do I run Linux commands in  
side a ruby program? I’ll print it out this time.

Thanks  
Jeff

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [July 16, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/system-commands/109568/2 "2007-07-16T23:36:21Z")

</div>

using system() or backticks ``

cmd = `uptime`  
puts cmd

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [July 16, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/system-commands/109568/3 "2007-07-16T23:52:22Z")

</div>

On 7/16/07, Jeffrey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Let me first apologize I asked this question last week  
> and lost the answer. How do I run Linux commands in  
> side a ruby program? I’ll print it out this time.

Michael answered your question, but to help you find old posts next time  
around:  
[http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml](http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml)

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [December 2, 2007, 12:40am UTC](https://www.ruby-forum.com/t/system-commands/109568/4 "2007-12-02T00:40:47Z")

</div>

I have a line like this:

response = `<some command>`

Why might it be that response is only NIL when that command is run  
through a rake task initiated by cron? If i just run the rake task  
normally it works fine.

Gregory B. wrote:

> On 7/16/07, Jeffrey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Let me first apologize I asked this question last week  
> > and lost the answer. How do I run Linux commands in  
> > side a ruby program? I’ll print it out this time.
> 
> Michael answered your question, but to help you find old posts next time  
> around:  
> [http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml](http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml)
