Hi,
For the system command, there is documentation on it here:
https://docs.epics-controls.org/en/latest/appdevguide/IOCShell.html
that explains you need to add the function registration to the database definition file. Was that done?
For your work-around, it could be automated by instead of executing the IOC st.cmd file directly to start the IOC, execute a bash script that first runs the Python program, and then the IOC st.cmd.
However, autosave should be working for the position restore. Can you us which version of the motor record you’re using? And does it have the RSTM field? The RSTM field was added in order to improve the options
regarding position restore:
(0:"Never", 1:"Always", 2:"NearZero", 3:"Conditional")
RSTM=2 is the default, and that reproduces the old behavior of restoring the position only if the controller position is zero (+/-MRES). So, make sure RSTM is not being set to 0.
There may be a version of the motor support module where the autosave restore method was changed, and before RSTM was added.
For some controllers and drivers you may need a short sleep (1s) after loading the driver and before executing the autosave functions and iocInit.
Also make sure you’re autosaving DVAL and not VAL.
Cheers,
Matt
From: Tech-talk <[email protected]>
On Behalf Of Tran, Phi Dung via Tech-talk
Sent: Friday, December 19, 2025 10:30 AM
To: Mark Rivers via Tech-talk <[email protected]>
Subject: [EXTERNAL] power off/on ioc recovery
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
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)
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
Run this Python script automatically during IOC startup (before iocInit) to ensure the restoration script always has the latest saved positions.
system("cd /path/to/script && /usr/bin/python3 generate_restore.py")
st.cmd line X: Command system not found.
- shell "command" - Command not found
- ! command - Command not found
- iocshCmd and iocshRun - Only execute EPICS commands, not shell commands
- OS: Red Hat Enterprise Linux 8.10
- IOC built from Galil motor driver (Galil-3-0/3-6)
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?
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!