<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ruby on technocracy</title><link>https://www.ericsimmerman.com/tags/ruby/</link><description>Recent content in Ruby on technocracy</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 13 Apr 2009 00:00:00 +0000</lastBuildDate><atom:link href="https://www.ericsimmerman.com/tags/ruby/index.xml" rel="self" type="application/rss+xml"/><item><title>Calling PHP from Ruby and reading STDOUT</title><link>https://www.ericsimmerman.com/blog/2009/04/13/calling-php-from-ruby-and-reading-stdout/</link><pubDate>Mon, 13 Apr 2009 00:00:00 +0000</pubDate><guid>https://www.ericsimmerman.com/blog/2009/04/13/calling-php-from-ruby-and-reading-stdout/</guid><description>&lt;div class='post'&gt;
PHP and Ruby syntax are far enough apart that I was loathe to attempt a port of some working PHP scripts in my arsenal, but I needed to call said scripts from a relatively complex Ruby program. Fast &amp;amp; dirty integration of this type is generally performed using a system call, but unlike most things Ruby I didn't find the Ruby way in this case to be all that intuitive.&lt;br /&gt;The %x technique for the system call made it easy to read the output of my PHP program into a variable in the calling script. The real trick was finding the correct syntax for passing a parameter to the %x call as shown below.&lt;br /&gt;Learn from my studies grasshopper:&lt;div class="CodeRay"&gt; &lt;div class="code"&gt;&lt;pre&gt;avariableparameter = &amp;quot;--o ipso -v lorem&amp;quot;result = %x[php /path/to/script.php &amp;quot;#{avariableparameter}&amp;quot;]&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description></item></channel></rss>