Executing php code in rails


#1

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?


#2

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