title: Launch node script from bash script
body: <p>I've my program in bash and I want to launch a node program to get the string that it return, like in this way:</p>
  <pre><code>#!/bin/bash
  
  mystring=$( node getString.js)
  mplayer $mystring
  </code></pre>
  <p>Googling I found that I should inlcude</p>
  <pre><code>#!/usr/bin/env node
  </code></pre>
  <p>But I need to use string to give it to mplayer.. any ideas?</p>
  <h2>Solution</h2>
  <p>As Zac suggesting (and thanks to <strong><a href="http://www.dzone.com/snippets/execute-unix-command-nodejs" rel="nofollow noreferrer">this link</a></strong>) I solved my problem in this way:</p>
  <p><strong>script.sh</strong></p>
  <pre><code>#!/bin/bash 
  
  mplayer ${1}
  </code></pre>
  <p><strong>script.js</strong></p>
  <pre><code>/* do whatever you need */
  var output=&quot;string&quot;
  var sys = require('sys');
  var exec = require('child_process').exec;
  function puts(error, stdout, stderr) { sys.puts(stdout);  }
  exec(&quot;./script.sh &quot; + output, puts);
  </code></pre>