title: Message between bash and JavaScript via named pipes
body: <p>I have a JavaScript application that needs to start a Linux application.</p>
  <p>Since I did not find any way to start the application and get when it ends, I made a bash script which launches the application, and sends a message via a named pipe when the app closes.</p>
  <p>Until here, all's good, but I can't find a way to catch this message in the JavaScript.</p>
  <p>Did someone know how to get the message in the JavaScript?</p>
  <p>I did search, but I only found how to do this in C# and C++.</p>
  <p>Sample from the JavaScript:</p>
  <pre><code>var test = spawn('sh', ['home/pi/play.sh', data.video_id]);
  </code></pre>
  <p>Just spawn a bash command which starts the script with the name of the video</p>
  <p>Sample from the bash:</p>
  <pre><code>mkfifo btjpipe
  if pgrep omxplayer
  then
      echo &quot;AR&quot;&gt;btjpipe
  else
      clear
      omxplayer $1 &gt; dev/null
      echo &quot;VE&quot;&gt;btjpipe
  </code></pre>
  <p>Created the pipe, seeking if the player is already running, then either send AR (&quot;Already Running&quot;) or start the player and send VE (&quot;Video End&quot;).</p>