I am trying to run a bash startup script that will run on startup and then will start a few Legato services as needed based on a scheduler.
From Command line: app start myapp - works fine
From command line using script: subprocess.call(‘app start myapp’, shell=True) when run inside script - works fine
Same script when run during startup - does nothing, just doesn’t start the service, no error, nothing
I tried changing out the subprocess call to: subprocess.call(‘/legato/systems/current/apps/appName/read-only/bin/appName’, shell=True) but it seems like it tries to run, but errors out instead of running like normal.
What is the proper way to call a Legato app from a script?
If you have an example app, that would be awesome as well.
Yes, I understand that. I have done both of those already, but I am trying to do it the other way around.
I want to call an app from a script.
For example, I want to poll GPS location every X hours from my script. I need the ability to call ‘app start myGPSapp’ from my script. That works fine when I run ‘app start myGPSapp’. It also works fine when I put it in my script and run the script manually from the command line. When I try to run it as a startup script, the startup script starts just fine, the time comes for the ‘app start myGPSapp’ to be called, but nothing ever happens.
I am thinking it may be a path issue. I only have a root user, so I don’t think it is permission issue.
did you modify /etc/init.d/startlegato.sh?
If yes, did you add some delay on the script with a new process (i.e. sh /home/root.test.sh &")as the legato framework might not start completely at this timeslot?
It allows you to run Python and python libraries on the FX30. Really slick code.
In the setup, if you put your bash script in /home/root/myapp/start.sh it will automatically run at boot.
It works great. I wrote a python scheduler and it will run processes every x seconds, x minutes, x hours, etc.
All the python code and functions work fine. I just can’t figure out how to call the Legato apps that I need to call periodically.
then in your python script, can it call a shell to run a script which is going to start the legato application?
if yes, then if you modify /etc/init.d/startlegato.sh, can it call the python script above?
then in your python script, can it call a shell to run a script which is going to start the legato application?
If my python script is run from the command line, it will start the legato application just fine using subprocess which is the way python runs command line calls. ie. subprocess.call(‘app start myapp’, shell=True)
When I run it as startup script, ALL the python functionality works, but the legato call does not work.
if yes, then if you modify /etc/init.d/startlegato.sh, can it call the python script above?
I don’t think I need to use startlegato.sh as the startup.sh starts the python scheduler just fine. It is the calls to ‘app start myGPSapp’ that don’t seem to work.
since your python script is OK to be run from the command line to call legato app, you can create a bash script to start your python script to start legato app
After that you can modify /etc/init.d/startlegato.sh to call this bash script with a new shell
since your python script is OK to be run from the command line to call legato app, you can create a bash script to start your python script to start legato app
If you are saying have my python scheduler (which is started in the bash startup script) , call a 2nd script which contains the subprocess call to the legato app, I tried that and it did not work.
After that you can modify /etc/init.d/startlegato.sh to call this bash script with a new shell