I don't know where to post this question because it's half a programming question and half a Linux question, so forgive me.
I'm working on a project using Beaglebone Black and I need to execute a very complex python script automatically after the boot, so I followed this tutorial:
(https://stackoverflow.com/questions/28854705/executing-a-script-on-startup-using-beaglebone-black)
which worked, but the script is executed in the /
directory and not in the correct directory, which is /root/pyfingerprint/examples/
, so when the program tries to execute things in the examples
directory it can't find them.
I tried adding a complete path for every line of code which required it and it worked for some parts of the project but it's not enough for cv2 and other libraries.
I tried to solve the problem simply adding os.system("cd /root/pyfingerprint/examples/")
at the beginning of the python script but when the program execute on boot it says that the current directory is still /
The program works perfectly when executed manually but not on boot time.
Is there a way to set the working directory of the service to automatically execute it in the right directory?
cd
in shell before execute main python script, notcd
inside the python script. You should show us how you execute your main python script if you need further assist. – 林果皞 Jun 04 '20 at 17:41cd /root/pyfingerprint/examples/;
inside shell script before run the python script(s)? – 林果皞 Jun 04 '20 at 17:52os.system()
has no effect as it creates a new process in which to do the operation. Instead useos.chdir('/....')
– meuh Jun 04 '20 at 18:31