user15841: I want to make a shell or C script that interprets the Arduino serial input to run commands. For that, I will need to make that script be the Serial monitor for my arduino. Another reason I want to use scripts or the command line as a Serial I/O is because the Arduino monitor function freezes the IDE.
My arduino's serial port is /dev/tty.usbmodem1d112
This is what I have tried so far:

cat /dev/tty.usbmodem1d112 < This returns absolutely nothing
screen /dev/tty.usbmodem1d112 < This Prints output, but has problems with input.
cat < /dev/tty.usbmodem1d112 < Same result as cat without the < symbol.

Sometimes, I also get annoying Resource Busy messages. This makes me re-plug the Arduino board.

OS X (10.9.5) Arduino IDE latest version. Arduino M0 pro board.

user10907: You'll need to condition the serial line with the stty command to get this to work. One of the easier ways to do it is to start by using the Serial Monitor and running the command:
stty -g < /dev/tty.usbmodem1d112
That will show you all of the settings that the Serial Monitor used to conditions the line. The -g flag to stty tells it to give you the results in a form that can be used as the arguments to another stty command. You could do this like this:
echo -n 'stty ' > stty.arduino ; sudo stty -g -f /dev/tty.usbmodem1d112 >> stty.arduino
chmod +x stty.arduino
The first line creates a shell script to condition the serial line. The second line makes it executable so that you can run it as a shell command – ./stty.arduino. The sudo runs the command as root (with elevated privilege) which allows you to open the port even though the Serial Monitor will already have it open.
If you want you could move the command into a directory on your $PATH (for example ~/bin) so that it can be found regardless of where your current directory is.
After getting set up you can see the output from Serial.println() on the Arduino by doing:
./stty.arduino
cat < /dev/tty.usbmodem1d112
Depending on what you are trying to do, you might find the expect or script commands helpful. Expect (man page) lets you automate interactions with a text based application or process. Script (man page) creates a transcript of your interactions on the command line with another program or process.

15841: <p>I want to make a shell or C script that interprets the Arduino serial input to run commands. For that, I will need to make that script be the Serial monitor for my arduino. Another reason I want to use scripts or the command line as a Serial I/O is because the Arduino monitor function freezes the IDE.</p>

<p>My arduino's serial port is <code>/dev/tty.usbmodem1d112</code></p>

<p>This is what I have tried so far:</p>

<ol>
<li><p><code>cat /dev/tty.usbmodem1d112</code> &lt; This returns absolutely nothing</p></li>
<li><p><code>screen /dev/tty.usbmodem1d112</code> &lt; This Prints output, but has problems with input.</p></li>
<li><p><code>cat &lt; /dev/tty.usbmodem1d112</code> &lt; Same result as cat without the <code>&lt;</code> symbol.</p></li>
</ol>

<p>Sometimes, I also get annoying <strong>Resource Busy</strong> messages. This makes me re-plug the Arduino board.</p>

<hr>

<p>OS X (10.9.5) Arduino IDE latest version. Arduino M0 pro board.</p>
 10907: <p>You'll need to condition the serial line with the <code>stty</code> command to get this to work. One of the easier ways to do it is to start by using the Serial Monitor and running the command:</p>

<p><code>stty -g &lt; /dev/tty.usbmodem1d112</code></p>

<p>That will show you all of the settings that the Serial Monitor used to conditions the line. The <code>-g</code> flag to stty tells it to give you the results in a form that can be used as the arguments to another stty command. You could do this like this:</p>

<p><code>echo -n 'stty ' &gt; stty.arduino ; sudo stty -g -f /dev/tty.usbmodem1d112 &gt;&gt; stty.arduino</code></p>

<p><code>chmod +x stty.arduino</code></p>

<p>The first line creates a shell script to condition the serial line. The second line makes it executable so that you can run it as a shell command – <code>./stty.arduino</code>. The <code>sudo</code> runs the command as root (with elevated privilege) which allows you to open the port even though the Serial Monitor will already have it open.</p>

<p>If you want you could move the command into a directory on your <code>$PATH</code> (for example ~/bin) so that it can be found regardless of where your current directory is.</p>

<p>After getting set up you can see the output from <code>Serial.println()</code> on the Arduino by doing:</p>

<p><code>./stty.arduino</code></p>

<p><code>cat &lt; /dev/tty.usbmodem1d112</code></p>

<p>Depending on what you are trying to do, you might find the <a href="http://www.admin-magazine.com/Articles/Automating-with-Expect-Scripts" rel="nofollow">expect</a> or <a href="http://www-users.cs.umn.edu/~gini/1901-07s/files/script.html" rel="nofollow">script</a> commands helpful. Expect (<a href="http://www.tcl.tk/man/expect5.31/expect.1.html" rel="nofollow">man page</a>) lets you automate interactions with a text based application or process. Script (<a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/script.1.html" rel="nofollow">man page</a>) creates a transcript of your interactions on the command line with another program or process.</p>
