Python script on start

More
7 years 2 months ago #142488 by marcopaluffi
Hi! Is possible run automatically a python script on a program start and other one script on the program end?
Thank you!

Please Log in to join the conversation.

More
7 years 2 months ago #142506 by pl7i92
Replied by pl7i92 on topic Python script on start
yes use a Mcode for your scripts to be started like M130
Code:
#!/usr/bin/python #my python myPython.py exit 0

you might set the io level bevore
mypyprogram.py &
or
halcmd setp iocontrol.0.lube_level 1

Please Log in to join the conversation.

More
7 years 2 months ago #142688 by marcopaluffi
Replied by marcopaluffi on topic Python script on start
Ok, thank you!
Can I insert python script into Mcode?
For example:
Code:
#!/usr/bin/python import os import sys txtfile= open('\home\user\Documents\test.txt', 'w') txtfile.write("TEST SCRIPT") txtfile.close() exit 0

Is there any other way to run automatically a python script on a program start without use a Mcode?
Thank you!

Please Log in to join the conversation.

More
7 years 2 months ago #143368 by andypugh
Replied by andypugh on topic Python script on start

marcopaluffi wrote: Is there any other way to run automatically a python script on a program start without use a Mcode?
Thank you!


You can run a HAL file on exit, automatically:
SHUTDOWN = .... linuxcnc.org/docs/2.7/html/config/ini-config.html#_hal_section

The HAL file could[1] "loadusr" a userspace HAL component that makes no pins, asserts "hal.ready" and then quits itself:
linuxcnc.org/docs/2.7/html/hal/halmodule.html

[1] Probably. I have never tried this.

Please Log in to join the conversation.

Time to create page: 0.321 seconds
Powered by Kunena Forum