i wrote a little script in python, i saved it into the SD card and i started it through Putty with the command
python /mnt/sda1/arduino/www/myScript.py
The script works, it downloads a .txt file from a FTP server and saves it on the SD card.
But when i try to run it from the Arduino sketch, it doesn't start. I read several topics but any of the solution i found works for me. Can you please check my software?
For example, I'd start out by first doing this word for word to test it, then modify it to your needs:
The runScript() function will create a Process that runs the script and prints the results to the Serial Monitor. Create a named Process, and start your script by calling Process.begin(filepath) and Process.run().
void runScript() {
Process myscript;
myscript.begin("/tmp/wlan-stats.sh");
myscript.run();
Keep in mind, you don't want to store any permanent files in /tmp as they will get wiped in this example. So if you create a shell script to launch your python script, keep it in your home folder.
Ive run scripts as you say and that should work.
Did you mount the sd card first? Each time Yun resets the sd card is unmounted.
Also, is very important to use absolute file paths inside the script, when using the open command you are not specifiyng the data.txt path, it should be like this: open('/path_to_file/data.txt', ..)
mart256:
Also, is very important to use absolute file paths inside the script, when using the open command you are not specifiyng the data.txt path, it should be like this: open('/path_to_file/data.txt', ..)
Thank you, the problem was the data file path inside the script! It has to be an absolute path. Now it works!