title: Call shell command within PhantomJS
body: <p>I wonder how to run shell command within PhantomJS, return back result of execution and assign it to variable.</p>
  
  <p>e.g. there is a phantomjs script:</p>
  
  <pre><code>var spawn = require("child_process").spawn
  var execFile = require("child_process").execFile
  
  var child = spawn("/usr/bin/php", ["script.php"])
  
  child.stdout.on("data", function (data) {
    console.log(JSON.stringify(data))
  })
  </code></pre>
  
  <p>and simple php script:</p>
  
  <pre><code>&lt;?php
  echo "test";
  ?&gt;
  </code></pre>
  
  <p>This example just prints to console "test", but how to use this returned data? Is it possible to assign it to variable and use it in next PhantomJS steps?</p>