How to call a c bin from a controller

Hi,
I am a newbee and for my project i have to call a C bin from the cgi-
bin rep of my host ,i want to call the script from my
controller…I’am sure it’s a trivial question but i havent found the
answer on google, I hope that someone could show my the right
solution,

here the Php script to call the CGI I want to do something like that
in my rails app

function urlSPPlus($urlCGI)

{
$handle = fopen($urlCGI, “rb”);
if (!$handle) { return “Error cgi script.”; }
$contents = fgetss($handle, 2048);
fclose($handle);
list($debut,$url,$fin) = split("’", $contents, 3);
return $url;
}

On 14 Mar 2008, at 09:06, Ecrevisse06 wrote:

Hi,
I am a newbee and for my project i have to call a C bin from the cgi-
bin rep of my host ,i want to call the script from my
controller…I’am sure it’s a trivial question but i havent found the
answer on google, I hope that someone could show my the right
solution,

IO.popen is probably what you want.

Fred

Thanks Fred, for yout help

But I think I don’t undesrtand something I have made some test

cgi-bin/hello.rb=> simple hello world
so in my controller:
IO.popen("…/…/…/cgi-bin/hello.rb", “w+”) do |pipe|
pipe.close_write
output = pipe.read
@output=output
end
in my view
<%[email protected]%> => “hello world”
its ok

but when i use the same script for the hmac_demo.exe (the real cgi
given by my bank)
the result in my view is an error with pipe.puts “my params”

text/html Status: 0 Unknown Request Method
Error 407 Unknown Request Method
Only POST or GET request methods are available

So I made a new test like that :
@urlcgihmac = “…/…/…/cgi-bin/hmac_wahine_decoration.exe”
@urlhmac = “#{@urlcgihmac}?
montant=#{@montant}&reference=#{@reference}&email=#{@email}&langue=#{@langue}&moyen=#{@moyen}&modalite=#{@modalite}”
IO.popen("#{@urlhmac}", “w+”)
…ect

but with that in my view I’haven’t got any result

please help me!

On Mar 14, 10:11 am, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs