title: Output breaking in child Process by nodejs
body: <p>I connected  <a href="http://www.google.com/imgres?q=wavecom%20gsm%20modem&amp;um=1&amp;hl=en&amp;sa=N&amp;biw=1280&amp;bih=880&amp;tbm=isch&amp;tbnid=Paht9jLVzyWsrM%3a&amp;imgrefurl=http://www.made-in-china.com/showroom/skylinestefanie/product-detailVMuJIZwPrOcG/China-Wavecom-16-Port-GSM-Modem-Bulk-SMS-Modem-USB-RS232-Interface-4-Kinds-of.html&amp;docid=AOTKF8FaBRwPtM&amp;imgurl=http://image.made-in-china.com/2f0j00FZctYUSLaTqI/Wavecom-16-Port-GSM-Modem-Bulk-SMS-Modem-USB-RS232-Interface-4-Kinds-of.jpg&amp;w=450&amp;h=450&amp;ei=2GtpT-WwOMrprAfi7anfBw&amp;zoom=1&amp;iact=hc&amp;vpx=199&amp;vpy=323&amp;dur=1527&amp;hovh=225&amp;hovw=225&amp;tx=125&amp;ty=128&amp;sig=105577733481107667276&amp;page=4&amp;tbnh=164&amp;tbnw=183&amp;start=71&amp;ndsp=25&amp;ved=1t:429,r:5,s:71" rel="nofollow">wavecom GSM modem</a> on ubantu. I use node.js language to communicate with GSM modem.
  I send command to modem by <a href="http://nodejs.org/api/child_process.html" rel="nofollow">Child Process</a>. Here example</p>
  
  <pre><code>var spawn         = require("child_process").spawn,
      exec          = require('child_process').exec;
  
   // Write dev_ttyUSB15.tmp file
   var child = exec('cat &lt; /dev/ttyUSB15 &gt; /tmp/dev_ttyUSB15.tmp');
  
   // Read dev_ttyUSB15.tmp file
   var m1 = spawn('tail',['-f','/tmp/dev_ttyUSB15.tmp']);
  
   // on data event is emitted when dev_ttyUSB15.tmp file has some data 
   m1.stdout.on('data', function (data) {
       console.log("Data : "+data); // this is executed as output
   });
  </code></pre>
  
  <p>Now When I fire some command on port /dev/ttyUSB15 I do not get output properly.</p>
  
  <p>E.g</p>
  
  <p>Suppose my output should be </p>
  
  <pre><code>Data : abcd1234
  </code></pre>
  
  <p>but instead of it I got</p>
  
  <pre><code>Data : abc
  Data : d1234
  </code></pre>
  
  <p>In short My output is breaked.
  I can not extrapolate from where my output exactly break. It's random.
  Can anyone give me any idea?</p>
  
  <p>Thanks in advance.</p>