|
Hello,
I'm trying to run a Python script from within my IOC startup script (st.cmd) to auto-generate a configuration file before iocInit(). However, I'm finding that the system() command is not available in my EPICS build.
Background - Motor Position Restoration Problem:
I need to restore motor positions after a Galil motor controller power cycle. I discovered that:
- Pass0 restore alone works when only restarting the IOC (controller stays powered on)
- Pass0 restore fails when the controller is power cycled - the controller resets to 0, and motor record initialization overwrites the restored VAL field with the controller's position (0)
My Solution:
I use SET mode after iocInit() to restore positions without motor movement. To avoid hardcoded values, I wrote a Python script (generate_restore.py) that reads the latest autosave file and generates the restoration script with
current saved values.
What I'm trying to do:
Run this Python script automatically during IOC startup (before iocInit) to ensure the restoration script always has the latest saved positions.
What I've tried:
system("cd /path/to/script && /usr/bin/python3 generate_restore.py")
Error received:
st.cmd line X: Command system not found.
Also tried:
- shell "command" - Command not found
- ! command - Command not found
- iocshCmd and iocshRun - Only execute EPICS commands, not shell commands
Environment:
- EPICS Base: R7.0.5
- OS: Red Hat Enterprise Linux 8.10
- IOC built from Galil motor driver (Galil-3-0/3-6)
Questions:
1. Is there a way to execute shell commands from within st.cmd in EPICS 7.0.5?
2. Is system() command availability dependent on build configuration or compile-time options?
3. Are there alternative approaches to run external scripts during IOC initialization?
4. Is there a better approach to handle motor position restoration after controller power cycle?
Current workaround:
Running python3 generate_restore.py && ./st.cmd manually before each IOC start, but I'd prefer an automated solution.
Any suggestions would be greatly appreciated!
Thanks,
Alex
|