Forum: Ruby on Rails Executing php code in rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
spacer (Guest)
on 2007-08-02 13:13
(Received via mailing list)
Hello guys. How could I execute a php script from RoR templates?

I've tried to do that in such way:
<% command = 'php /site/script.php uri=' %>
<%= `#{command}` %>

And got this:
X-Powered-By: PHP/4.4.7 Content-type: text/html require
File.dirname(__FILE__) + "/../config/environment" unless defined?
(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require
should be changed to an absolute path one, like: # "/usr/local/lib/
ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise
performance is severely impaired require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

What I've done wrong?
Faisal N Jawdat (Guest)
on 2007-08-02 23:18
(Received via mailing list)
On Aug 2, 2007, at 5:12 AM, spacer wrote:
> <% command = 'php /site/script.php uri=' %>
> <%= `#{command}` %>

trying:

  <% command = 'hostname' %>
  <%= `#{command}` %>

...everything works.  i'm guessing you have some path problem -- try
explicitly setting the php path, e.g. "/usr/local/bin/pgp /site/
script.php uri="

-faisal
This topic is locked and can not be replied to.