user10236: How can I convert a string like the following:
"pinMode(2, INPUT_PULLUP)"

or

'Keyboard.print("Hello world")'

into actual code that the Arduino can act on?

user4143: You can't - not directly.
There are two things you can do:

Build your "command" into a sketch and compile it, then upload it in to the Yun's AVR chip.  The compiling will have to be done on your PC, and the HEX file uploaded to the AVR (you can do it directly through the Yun's web interface).
Don't send sketch code, but send pre-defined instructions like "Turn on pin 3" which your sketch then interprets.  That could be as simple as two bytes "P3" for instance.  It's entirely up to you how you craft that.

Firmata might help with option 2 if uploading a new sketch every time isn't what you want to do.

user7508: There is a third option: install an interpreter on the Arduino, then
just send it the program you want it to run. There are a few such
interpreters available. A quick search showed:

Bitlash, a C-like language
iArduino, another
C-like language
FlashForth, a
Forth
implementation
FINF Is Not Forth, a Forth-like
language

There are probably many others.
The difference between this option and Majenko's option 2 is that this
would allow you to send a complete program, with functions,
conditionals, loops, etc., whereas with a Firmata or similar approach
you would keep the program logic (functions, loops, conditionals) on the
host computer, and only send simple commands to the Arduino.

10236: <p>How can I convert a string like the following:</p>

<pre><code>"pinMode(2, INPUT_PULLUP)"

or

'Keyboard.print("Hello world")'
</code></pre>

<p>into actual code that the Arduino can act on?</p>
 4143: <p>You can't - not directly.</p>

<p>There are two things you can do:</p>

<ol>
<li><p>Build your "command" into a sketch and compile it, then upload it in to the Yun's AVR chip.  The compiling will have to be done on your PC, and the HEX file uploaded to the AVR (you can do it directly through the Yun's web interface).</p></li>
<li><p>Don't send sketch code, but send pre-defined instructions like "Turn on pin 3" which your sketch then interprets.  That could be as simple as two bytes "P3" for instance.  It's entirely up to you how you craft that.</p></li>
</ol>

<p>Firmata might help with option 2 if uploading a new sketch every time isn't what you want to do.</p>
 7508: <p>There is a third option: install an interpreter on the Arduino, then
just send it the program you want it to run. There are a few such
interpreters available. A quick search showed:</p>

<ul>
<li><a href="http://bitlash.net/" rel="nofollow">Bitlash</a>, a C-like language</li>
<li><a href="http://n.mtng.org/ele/arduino/iarduino.html" rel="nofollow">iArduino</a>, another
C-like language</li>
<li><a href="http://flashforth.com/" rel="nofollow">FlashForth</a>, a
<a href="http://en.wikipedia.org/wiki/Forth_%28programming_language%29" rel="nofollow">Forth</a>
implementation</li>
<li><a href="https://github.com/lpereira/finf" rel="nofollow">FINF Is Not Forth</a>, a Forth-like
language</li>
</ul>

<p>There are probably many others.</p>

<p>The difference between this option and Majenko's option 2 is that this
would allow you to send a complete program, with functions,
conditionals, loops, etc., whereas with a Firmata or similar approach
you would keep the program logic (functions, loops, conditionals) on the
host computer, and only send simple commands to the Arduino.</p>
