Gateway Script - system.util.execute

Hello all,

I’m working on a project where we need to run a batch file (on the gateway server) on demand from the clients.

The batch file takes care of some database housekeeping (namely copying MS Access database tables into MySQL for use in reporting), and we would like to have a simple “refresh” button that executes this batch file on the gateway.

Using the designer (a designer running on the gateway) I succesfully added a script on mouse click to a button component. The script code is simple:

system.util.execute(["C:\\Users\\Administrator\\Desktop\\cworkstomysql.bat"])

A quick switch to preview mode and a click of the button does indeed cause the batch file to run, and I have verified that the data is indeed copied from the MS Access database to the MySQL database. However, what we really need is for that script to always execute on the gateway server and not on client hardware. The idea was to use a button that toggles a tag, causing a gateway script to execute using the same code.

The problem I’m having is that I can’t seem to get the same script to work within a gateway script triggered on tag change. I have a Gateway Event Script (Tag Change) set up to trigger on a SQLTag, and the script that is slated to execute is the exact same script in the code box above. Changing the trigger tag doesn’t cause any updating to occur within the MySQL database, as it did with the button script.

I feel like I’m missing some kind of obvious syntax thing here, but can’t find much help searching the forums or the help literature.

Any thoughts?

Any errors that occur while running a Gateway Event Script will be logged to the wrapper.log file in your install directory (C:\Program Files\Inductive Automation\Ignition\logs). What error is the script causing?

Thanks for the tip, Robert.

I checked out the wrapper.log and didn’t see any error messages pertaining to the gateway event scripts. Seeing this, though, reminded me that in my haste (and perhaps being too comfortable with the designer’s “preview” mode) I had neglected to realize that these changes to the gateway event scripts weren’t actually live on the gateway until I saved the project’s changes and published them.

So the “stupid mistake” I predicted was, in fact, slightly stupider than predicted.

But anyway, that did the trick. Tag changes are now triggering the script, as expected.

Thanks again.