Moved to the Yun forum: Using Process.runShellCommand to start Python Program - Arduino Yún - Arduino Forum
Hi all --
I'm trying to start a python program on the Linino from the Arduino. This is what I've got:
Arduino Code
#include <Process.h>
void setup() {
Bridge.begin(); // Initialize the Bridge
Serial.begin(9600); // Initialize the Serial
Process p;
p.runShellCommand("/root/run_my_python.sh");
// do nothing until the process finishes, so you get the whole output:
while (p.running()){ ; }
while (p.available()) { ; }
delay(5000);
}
void loop() { }
On the Linino, in a file called run_my_python.sh in /root:
#!/bin/sh
python /root/my_python_program.py
On the Linino, in a file called my_python_program.py in /root:
import os
os.system('touch /root/touched')
When I run
$ /root/run_my_python.sh
in the terminal, a file in /root named touched
successfully gets created. However, when I run this from the Arduino, no file gets created. What am I doing wrong?
Perhaps this is related to some other issues I observed with runShellCommand, here: MOVED TO YUN: Process.runShellCommand - Shell program executed repeatedly - Installation & Troubleshooting - Arduino Forum
Thanks a bunch!