How to I pass parameters to Ruby/Python scripts from inside PHP?
Posted
by
Roger
on Stack Overflow
See other posts from Stack Overflow
or by Roger
Published on 2011-01-06T21:20:57Z
Indexed on
2011/01/06
23:53 UTC
Read the original article
Hit count: 299
Hi, everybody.
I need to turn HTML into equivalent Markdown-structured text. From what I could discover, I have only two good choices:
Python: Aaron Swartz's html2text.py
As I am programming in PHP, I need to pass the HTML code, call the Ruby/Python Script and receive the output back.
I started creating a simple test just to know if my server was configured to run both languages.
PHP code:
echo exec('./hi.rb');
Ruby code:
#!/usr/bin/ruby
puts "Hello World!"
It worked fine and I am ready to go to the next step.
Unfortunately, all I know is that the function is Ruby works like this:
HTML2Markdown.new('<h1>HTMLcode</h1>').to_s
I don't know how to make PHP pass the string (with the HTML code) to Ruby nor how to make the ruby script receive the variable and pass it back to PHP (after have parsed it into Markdown). Believe it or not: I know less of Python.
A folk made a similar question here ("how to call ruby script from php?") but with no practical information to my case.
Any help would be a joy - thanks.
Rogério Madureira.
atipico.com.br
© Stack Overflow or respective owner