On Jul 14, 7:31 am, Hans Hartmann <[email protected]>
wrote:
> I try and try...
> but I can't make the script be executed (nor an other Programm)
> Can someone give me an example to execute external files with rails? So
> I can get an idea of the path-description.
>
> Thx a lot
> --
> Posted viahttp://www.ruby-forum.com/.

What you are looking for is the backtick '`' method of Kernel, aliased
as %x().  You should refer to the official api at http://ruby-doc.org/core/
and read this carefully.

Rails is a framework not a programming language.  So it is really a
default directory layout supported by a vast amount of clever code to
do most of the grunt work required to write web apps.  As other have
pointed out, Ruby is the language used.  To run one Ruby script from
another your would have something that looked like this, more or less.

caller.rb
#!/usr/bin/env ruby
# call the other script and open an new shell
%x(path/to/my/other/script.rb)
#eof

script.rb
#!/usr/bin/env ruby
puts "script.rb has been called"
#eof

Now, this will display nothing because the stdout of the target script
is not looked for in the calling script, which is the one you ahve
open in your console. So:

caller.rb
#!/usr/bin/env ruby
# call the other script and open an new shell
my_stdout = %x(path/to/my/other/script.rb)
puts my_stdout
#eof

That should display the output of script.rb on the console running
caller.rb.  script.rb's stderr can be redirected as well:

caller.rb
#!/usr/bin/env ruby
# call the other script and open an new shell
my_stdout = %x(path/to/my/other/script.rb 2> &1)
puts my_stdout
#eof

HTH
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to