1

i need to run a python script from an arduino yun sketch.

the python file resides here:

/mnt/sd/arduino/www/python/python.py

... and this is the arduino sketch:

#include <Console.h>
#include <Process.h>

void setup() {
   Bridge.begin();
    Console.begin();   
    pinMode(A0, INPUT);  

  }

  void loop() {   
  if(analogRead(A0) > 200){
  Process p;
  Console.println("Limit....");
  p.runShellCommand("python /mnt/sd/arduino/www/python/python.py");
  delay(1000);   
  }

  Console.println(analogRead(A0));
  delay(100);
  }

if i run the python file from Winscp window, it works fine. I think there is a problem with the path...

thanks in advance...

pasluc74669
  • 1,680
  • 2
  • 25
  • 53
  • what happens if you use the full path to python presumably: `p.runShellCommand("/usr/bin/python /mnt/sd/arduino/www/python/python.py");` ? – nettux Nov 24 '15 at 17:06
  • it happens the same thing, i also added this code at the end of the script: file = open("i_ran_yo.txt", "w") file.write("code ran\n") file.close() - in the local pc it creates a txt file, but in linino it don't happens the same!! – pasluc74669 Nov 24 '15 at 17:14
  • i created a new py file in /mnt/sd/arduino/www/python/ folder (the same folder of the others scipts) with the command print (os.path.abspath(__file__)), and it returns me this path: C:\Users\MyName\AppData\Local\Temp\scp35571\mnt\sd\arduino\www\python – pasluc74669 Nov 24 '15 at 17:37
  • Did you find a solution for your problem? – raphael_mav May 30 '19 at 15:06

0 Answers0