title: Redirecting AT commands to microcom command under Linux
body: <p>in the <code>BusyBox</code> <a href="http://en.wikipedia.org/wiki/BusyBox">command</a> for Linux exists the command <code>microcom</code> to communicate with a serial modem:</p>
  
  <pre><code>BusyBox v1.13.2 (2012-05-10 17:13:08 CEST) multi-call binary
  
  Usage: microcom [-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY
  
  Copy bytes for stdin to TTY and from TTY to stdout
  
  Options:    
          -d  Wait up to DELAY ms for TTY output before sending every next byte to it
          -t  Exit if both stdin and TTY are silent for TIMEOUT ms
          -s  Set serial line to SPEED
          -X  Disable special meaning of NUL and Ctrl-X from stdin
  </code></pre>
  
  <p>Instead of using stdin to type the AT commands I want to place them insise a text file and redirect the content of that file as the stdin for the above command. For example, I have a file</p>
  
  <pre><code>/tmp/at.txt
  </code></pre>
  
  <p>with the AT command <code>AT</code>, which usually gets confirmed by the TTY with an <code>OK</code>. A standard session with stdin looks like:</p>
  
  <pre><code>microcom -t 3000 -X /dev/ttyS5                                 
  at
  OK
  </code></pre>
  
  <p>in which the string <code>at</code> was entered directly on the keyboard. In order to use the content of the file <code>/tmp/at.txt</code> (contains just 'at\n'). To do this,. I have tried the following variations:</p>
  
  <pre><code>microcom -t 3000 -X /dev/ttyS5  &lt; /tmp/at.txt   
  microcom -t 3000 /dev/ttyS5  &lt; /tmp/at.txt 
  cat /tmp/at.txt |  microcom -t 3000 /dev/ttyS5
  tail -f  /tmp/at.txt |  microcom -t 3000 /dev/ttyS5
  cat /tmp/at.txt |  microcom -t 3000 /dev/ttyS5 -X
  tail -f  /tmp/at.txt |  microcom -t 3000 /dev/ttyS5 -X
  </code></pre>
  
  <p>and none of them worked, i.e. none of those commands did return the text 'OK' on the screen. I therefore conclude that there is some problem redirecting the content of the file <code>/tmp/at.txt</code> as stdin for the command <code>microcom</code>. Maybe is has to do with how the end-of-line is interpreted or the end-of-file. If someone has some idea, I would appreciate some help. </p>
  
  <p>Thanks, </p>
  
  <p>Alex</p>