Go Down

Topic: How to setup environment variables for run Process from sketch? (Read 3024 times) previous topic - next topic

Vir

Hi, everybody.

I need set up environment variables, like LD_LIBRARY_PATH. I call to python script from my arduino sketch by using Process. But in this script I need LD_LIBRARY_PATH.

For root console no problems, because I just created ~/.profile with export LD_LIBRARY_PATH=/path/to/lib, and it's works fine. But how I can do something from sketch?

I tried to run "export LD_LIBRARY_PATH=/path/to/lib" by Process, but it's not working. After that I tried run "env" and read the answer, and LD_LIBRARY_PATH was not exported.

ShapeShifter

Each time you run something with a Process call, you are starting a Linux process, running it, and then terminating. The next Process invocation starts from scratch. There is no continuity from one Process invocation to the next. It's as if you logged in, ran the first command, then logged out; then logged back in, ran the second command, and logged out again. Setting the environment in the first Process will not affect the second Process.

If you need to run multiple commands in the same context, you need to do it in one Process invocation. I suggest that you write a shell script that does all of your steps: sets the environment variables, changes directories, runs your Python script, etc. Then run that shell script from your Process invocation.o

Go Up