Running a shell script from Arduino

Hi all,

I'm a software developer, but completely new to Arduino.
I would like to make a simple project that combined both worlds, this project should include an Arduino connected to a mac via USB, on the mac I have a shell script "myscript.sh", and on the Arduino side I got a button.
when pressing the button I want to run the shell script, like you would do from the mac's terminal.

I saw some tutorials about how to use buttons, and how to send info using Serial,
my main concern here is how to make the Arduino run a script file that stored on the mac.
Is it possible to directly run a shell command from the Arduino code? if not what are my other options to run the script?

In general you will need a program running on your PC that receives the data from the Arduino and, when appropriate, runs the shell script. The Arduino cannot control a PC directly.

I guess if you have a program on a Leonardo that emulates a keyboard you may be able to cobble something together without needing a program on the PC

...R

(By PC I mean any of Linux, Mac or Windows)

Hi Rubin, so if I understand right, I should have some kind of listener app on my mac that polling the serial port and wait for some data from the Arduino?

I have a hardware question if you don't mind,
will Arduino Uno be ok for this kind of project?
as I understood it has a single USB connection that also used to upload sketches to the Arduino, is that also the connection I should use to connect to the mac for transferring data?

Hi.

Just take a look here:
Running a listening script on my linux box, and reply data to arduino.
I keep it simple in linux side, due to processes running limitation over linux.
Every one suggest python, I tried pearl with some success too.

http://forum.arduino.cc/index.php?topic=306767.msg2137305#msg2137305

I used a mini-pro and a UNO.
I based my arduino code from Robin“s "serial Input basic tutorial ";
Serial Input Basics - Programming Questions - Arduino Forum to get the data from linux.
I didn't use USB connection, Connection is by serial ttl from the PC to arduino over serial pin.

roykarn:
I have a hardware question if you don't mind,
will Arduino Uno be ok for this kind of project?
as I understood it has a single USB connection that also used to upload sketches to the Arduino, is that also the connection I should use to connect to the mac for transferring data?

The Uno should be fine. Obviously you can't upload a new program while you are listening for output from the Arduino. But you couldn't do that regardless of how the Arduino is connected to the PC.

If you don't want to tie up a USB port on your PC you could perhaps communicate with Bluetooth.

This Python-Arduino demo may be useful. It would be easy to adapt it to run your shell script when it receives a particular message.

...R

thanks for your help guys,

Robin I will defiantly check the Bluetooth option, I suppose I need to get some kind of Bluetooth component for that, as I searched google I saw two kind of components one is Bluetooth shield and the other is Bluetooth module. will both work for me? do I need to check for any special modal or compatibility issues?

And if you have any reference to a good bluetooth-arduino-connection example I will really appreciate it.

I believe the cheapest Bluetooth modules won't work with a Mac, but I don't remember how to describe the ones that do. Google should find it for you in another Thread.

Personally I have so far avoided using shields because of the expense and because they are less flexible in the use of Arduino I/O pins. There is also the price question.

...R