# Running an executable local file with a Ruby script?

**URL:** <https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737>\
**Category:** Ruby\
**Created:** [August 24, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737 "2008-08-24T22:03:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/1 "2008-08-24T22:03:57Z")

</div>

I’m having a lot of problems just running an executable local file with  
a Ruby script. I go to the directory with the file (call the executable  
file ‘mkplots’), then try to run that file.

I’ve tried all sorts of system and back-quoted commands, and nothing  
works. If I go to the UNIX command line and simply type the file name,  
it runs fine.

What am I doing wrong?? Why doesn’t the following command work:

system( “mkplots” )

— or —

`mkplots`

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 10:20pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/2 "2008-08-24T22:20:57Z")

</div>

Joost D. wrote:

> Thomas L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:
> 
> > system( “mkplots” )  
> > Is the current path in your PATH environment variable? If not, use
> 
> system( “./mkplots” )

I’ve tried that. I don’t get any errors, but it also doesn’t produce  
any output (like it does if I use the command line).

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 10:14pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/3 "2008-08-24T22:14:02Z")

</div>

Thomas L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> system( “mkplots” )  
> Is the current path in your PATH environment variable? If not, use

system( “./mkplots” )

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/4 "2008-08-24T22:31:09Z")

</div>

Replace ./mkplots with a very simple executable (or script) which does  
something like writing to a file, including any error messages sent to  
stderr. Temporarily (!) give it maximal permissions, before reducing it  
to the same permissions as mkplots.

This will allow you to see whether the executable is actually being  
executed or not and whether any errors are being generated. In my  
experience there are often problems with permissions, especially if the  
script is being run by a web server.

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 11:02pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/5 "2008-08-24T23:02:30Z")

</div>

Dave B. wrote:

> Replace ./mkplots with a very simple executable (or script) which does  
> something like writing to a file, including any error messages sent to  
> stderr. Temporarily (!) give it maximal permissions, before reducing it  
> to the same permissions as mkplots.
> 
> This will allow you to see whether the executable is actually being  
> executed or not and whether any errors are being generated. In my  
> experience there are often problems with permissions, especially if the  
> script is being run by a web server.

This is kind of dumb (and certainly not ‘The Ruby Way’, but I got it to  
work with this workaround.

(1) Create a little Korn shell file (save as make\_plots.sh, change  
permissions with a `chmod +x make_plots.sg` ):

_#! /bin/ksh_  
_mkplots_

(2) Run it with the following command in Ruby

system( “make\_plots.sh” )

However, this really offends me to have to do this, so any further ideas  
are welcome…

---

<div class="post-metadata">

**Author:** ![tlockney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@tlockney](https://www.ruby-forum.com/u/tlockney)\
**Post date:** [August 24, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/running-an-executable-local-file-with-a-ruby-script/146737/6 "2008-08-24T23:55:57Z")

</div>

I am not familiar enough with calls in Ruby to system in Linux at this  
moment, but in Windows, I was recently doing this, and had to use  
something  
like this: system"call command"

If I simply did system"command" it did not operate like I expected.
