# Using system() to execute a script outside of Rails but in a

**URL:** <https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404>\
**Category:** Rails\
**Created:** [July 26, 2007, 1:34am UTC](https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404 "2007-07-26T01:34:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 26, 2007, 1:34am UTC](https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404/1 "2007-07-26T01:34:31Z")

</div>

I’m trying to hack around a previously mentioned RMagick problem,  
confirmed to exist inside of Rails but not outside.  
Thus, I’d like to call a Ruby script from with in a Rails controller.  
Like so:  
system("#{RAILS\_ROOT}/public/images/thumb\_and\_comp.rb",  
“#{@asset.file\_name}”)

But it never seems to get executed.  
Permissions are set to 755 on the script.  
Any suggestion?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 26, 2007, 2:39am UTC](https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404/2 "2007-07-26T02:39:37Z")

</div>

If you’re just trying to do thumbnails, better to look at how  
file\_column or a similar plugin accomplish that than to shell out to  
a different process. Rails is a one-in-one-out pipe, so blocking  
requests on a shell process could really screw up your performance.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 26, 2007, 4:04am UTC](https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404/3 "2007-07-26T04:04:43Z")

</div>

I know Rails is a single threaded process, because Ruby is as well.  
But at this point even the maintainer of RMagick (who I’ve been  
talking to a lot the last few days) is mystified by how my thumbs can  
be correct when run from a straight Ruby script on the same system,  
but through Rails it gets screwed up.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 26, 2007, 6:14am UTC](https://www.ruby-forum.com/t/using-system-to-execute-a-script-outside-of-rails-but-in-a/110404/4 "2007-07-26T06:14:49Z")

</div>

Well, I dunno, but I used file\_column on one of my sites that’s been  
happily purring away and the relevant code is:

img = ::Magick::Image::read(absolute\_path).first  
resize\_image(img, version\_options[:geometry], absolute\_path(name))

Where version\_options[:geometry] is, as you might expect, the  
geometry to resize to a thumbnail. Are you doing something different?
