Starting Python (and / or any other Service or Script on startup)

bhouston asked if it was possilbe to start with Python service automatically on startup. I'll be including bat files which do this again shortly, but in the interim I'll show you how to create your own.

From the command line you can start any service(s) in addition you can actually invoke any command too... You could automatically run a script, which potentially is quite powerful.

This is how ..

In your favorite text editor make a myrobotlab.bat file next to the myrobotlab.jar

Edit the file and put the following line.

 

java -jar myrobotlab.jar -service gui GUIService python Python

 

The -service says which services to start .. the following parameters will be in pairs.
The Service "name". In this case "gui" and "python" followed by their Service Type GUIService & Python respectively.

That's it !

To invoke a command .. say automatically execute a python script do the following

java -jar myrobotlab.jar -service gui GUIService python Python -invoke python execFile myScript.py

This tells the Service name "python" to run the exeFile method with the parameter of "myScript.py" .. so basically execute myScript.py on startup.

Within the script you could do pretty much anything else, start a robot, start the kinect, speak the joke of the day...

The myScript.py would need to be in the same directory as the other two files (myrobotlab.bat & myrobotlab.jar) like this....

new myrobotlab.bat & myScript.py

myScript.py... in this case it just starts a servo

And viola !.. a python service & a servo automagically created on startup :)

 


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
beetlejuice's picture

cool

Very good thing ! thanks, i'll just asked why python stopped to launch at start like before ...

You answered before i ask , too strong lol !

ambroise's picture

it is cheenese for me.......

it is cheenese for me.......

AdolphSmith's picture

Nice

I like this . So this is where inmoov become stand alone.

Nice Grog i did it work 100%

I create myscrip.bat and edit it and put this in my bat file : 

java -jar myrobotlab.jar -service gui GUIService python Python -invoke python execFile darwinwiggle.py 

Now all start with one button.

Thank you Grog

GroG's picture

You are Python Guru

dwilli9013's picture

Mechanical Love

Thanks Grog you just keep making it easier and easier for us mechanical non programming types.

By the way heres a tip for the one you gave me on the web gui.

If you just right click and pick open in new tab it works as in days of old.yes You sir are still Dah Man