EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
<== Date ==> <== Thread ==>

Subject: power off/on ioc recovery
From: "Tran, Phi Dung via Tech-talk" <[email protected]>
To: Mark Rivers via Tech-talk <[email protected]>
Date: Fri, 19 Dec 2025 15:29:42 +0000
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

Replies:
RE: power off/on ioc recovery Pearson, Matthew via Tech-talk

Navigate by Date:
Prev: AreaDetector Collaboration Meeting - January 8th Érico Nogueira Rolim via Tech-talk
Next: RE: power off/on ioc recovery Pearson, Matthew via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
Navigate by Thread:
Prev: AreaDetector Collaboration Meeting - January 8th Érico Nogueira Rolim via Tech-talk
Next: RE: power off/on ioc recovery Pearson, Matthew via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  <20252026 
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·