Doesn't really answer your main question but in my opinion the better approach is to put your control logic in python and interact with ngspice through the shared library interface. PySpice has an implemented python interface.
To my mind putting effort into learning ngspice's quirky way of doing things is wasted effort. If you want to use Xyce or something else you need to throw everything away and start again. It's worth decoupling the analysis from the simulation calculation