# Where is the difference between \>system "script/myscript"\< and \>script/myscript\< (via shell)?

**URL:** <https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344>\
**Category:** Rails\
**Created:** [October 20, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344 "2008-10-20T16:05:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![none](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@none](https://www.ruby-forum.com/u/none)\
**Post date:** [October 20, 2008, 4:05pm UTC](https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344/1 "2008-10-20T16:05:26Z")

</div>

hallo everybody,

i’ve searched the web for quite some time now, but didn’t find an  
answer to this question (and thus no solution to my problem).

explanation:  
i wrote a script to start a DRb-server on a rails-app. what i want to  
achieve is to run this script from another application (on the same  
machine). everything is working perfectly when i start myscript from a  
shell and enter “script/myscript” (without quotes). but when i call it  
from my other application like this: system “#{path}/script/myscript”  
my tests are failing…

of course there is the obvious difference in ENV[’\_’], but even  
changing this manually wouldn’t help. i’m looking for a way to get a  
“clean” call. (just like from shell)

any ideas?

thanks in advance  
dominik

---

<div class="post-metadata">

**Author:** ![none](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@none](https://www.ruby-forum.com/u/none)\
**Post date:** [October 20, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344/2 "2008-10-20T16:27:14Z")

</div>

On 20 Oct 2008, at 15:04, none wrote:

> shell and enter “script/myscript” (without quotes). but when i call it  
> from my other application like this: system “#{path}/script/myscript”  
> my tests are failing…

current working directory is one obvious difference that does screw up  
some things.

Fred

---

<div class="post-metadata">

**Author:** ![none](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@none](https://www.ruby-forum.com/u/none)\
**Post date:** [October 21, 2008, 9:43am UTC](https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344/3 "2008-10-21T09:43:36Z")

</div>

> current working directory is one obvious difference that does screw up  
> some things.
> 
> Fred

thanks for your quick response!  
still, it’s not working. everytime i call an instance-method of  
‘some\_class’ in my remote application, it crashes.

without copy/paste-ing a whole bunch of code, here is what happens (in  
pseudocode):

```auto
>> myobject = MyObject.new
>> myobject.save
>> myobject.my_instance_method!
NameError: uninitialized constant MyObject::RemoteAppControlClass
        from (druby://localhost:9003) /home/n0ne/_files/work/_code/
my_remote_app/vendor/rails/activerecord/lib/../../activesupport/lib/
active_support/dependencies.rb:478:in `const_missing'
        from (druby://localhost:9003) ./app/models/my_object.rb:95:in
`my_instance_method!'
        from (druby://localhost:9003) /home/n0ne/_files/work/_code/
my_remote_app/lib/drb_server.rb:30:in `some_method'
        from /home/n0ne/_files/work/_code/my_local_app/app/models/
my_object.rb:97:in `my_instance_method!'
        from (irb):6
```

explanation:

- there are two rails-apps ‘my\_local\_app’ and ‘my\_remote\_app’
- both apps share a common database-connection for ‘MyObject’ (with  
the plugin use\_db)
- when ‘my\_local\_app’ calls ‘my\_instance\_method!’ it’s redirected (via  
drb\_server) to ‘my\_remote\_app’ and ‘my\_instance\_method!’ gets  
evaluated there
- when starting both apps individually this works great! which means  
there is no fundamental error in my code.
- when starting ‘my\_remote\_app’ through the ‘remote\_app\_control\_class’  
i get that weird error.
- a manual start is done by calling ‘script/start\_remote\_app’
- a remote startis done in ‘my\_local\_app’ by the  
‘remote\_app\_control\_class’ calling ‘system “#{path}/script/  
start\_remote\_app”’

i can only assume, that there is a problem with the environment ENV or  
something similar. is there a way of getting a clean/fresh ENV for my  
system call (so that it is just like i would have started it  
manually)?

thanks again  
dominik

---

<div class="post-metadata">

**Author:** ![none](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f19dbf/32.png) [@none](https://www.ruby-forum.com/u/none)\
**Post date:** [October 21, 2008, 10:32am UTC](https://www.ruby-forum.com/t/where-is-the-difference-between-system-script-myscript-and-script-myscript-via-shell/151344/4 "2008-10-21T10:32:52Z")

</div>

On 21 Okt., 09:43, none [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > current working directory is one obvious difference that does screw up  
> > some things.
> 
> > Fred

man, nevermind! i got it. and: you were right, of course! it was the  
working directory.  
i just had some other stuff failing, so my first tries with changing  
the working directory failed as well.

just tried it again and succeeded.

thanks fred

ps: nice talk at the railsconf europe this year! building smaller apps  
instead of one big one really got me thinking… thanks!
