# Gateway Script

**URL:** <https://forum.inductiveautomation.com/t/gateway-script/2799>\
**Category:** Ignition\
**Created:** [March 23, 2011, 6:01pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799 "2011-03-23T18:01:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon.Trusik](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jon.Trusik](https://forum.inductiveautomation.com/u/Jon.Trusik)\
**Post date:** [March 23, 2011, 6:01pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799/1 "2011-03-23T18:01:42Z")

</div>

I have a script that runs fine as a client script, however when I try it as a Gateway script, it fails. I need to create a file and write data to it at a specific time. The data I am using are expression tags from [Client] tags group. Is this the problem?  
Here is the info from the Gateway console error, I’ve also included the script I’m trying to run…

com.inductiveautomation.ignition.gateway.web.pages.config.systemconsole.LogViewer$SerializableLoggingEvent$ClonedThrowable: null  
org.python.core.Py.NameError(Py.java)com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.getTagValue(AbstractTagUtilities.java:61)sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)java.lang.reflect.Method.invoke(Unknown Source)org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java)com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:310)org.python.core.PyObject. **call** (PyObject.java)org.python.core.PyObject.invoke(PyObject.java)org.python.pycode.\_pyx3.f$0(\<TimerScript:Production File (60000) [Delay, Shared]\>:12)org.python.pycode.\_pyx3.call\_function(\<TimerScript:Production File (60000) [Delay, Shared]\>)org.python.core.PyTableCode.call(PyTableCode.java)org.python.core.PyCode.call(PyCode.java)org.python.core.Py.runCode(Py.java)com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:72)java.util.TimerThread.mainLoop(Unknown Source)java.util.TimerThread.run(Unknown Source)  
com.inductiveautomation.ignition.gateway.web.pages.config.systemconsole.LogViewer$SerializableLoggingEvent$ClonedThrowable: null  
org.python.core.Py.NameError(Py.java)com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.getTagValue(AbstractTagUtilities.java:61)sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)java.lang.reflect.Method.invoke(Unknown Source)org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java)com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:310)org.python.core.PyObject. **call** (PyObject.java)org.python.core.PyObject.invoke(PyObject.java)org.python.pycode.\_pyx3.f$0(\<TimerScript:Production File (60000) [Delay, Shared]\>:12)org.python.pycode.\_pyx3.call\_function(\<TimerScript:Production File (60000) [Delay, Shared]\>)org.python.core.PyTableCode.call(PyTableCode.java)org.python.core.PyCode.call(PyCode.java)org.python.core.Py.runCode(Py.java)com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:72)java.util.TimerThread.mainLoop(Unknown Source)java.util.TimerThread.run(Unknown Source)  
[Gateway Script.txt](https://us1.discourse-cdn.com/inductiveautomation/original/1X/a9ab7c91e94994238876833dd3df0561ac77fb81.txt) (2.15 KB)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 23, 2011, 6:02pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799/2 "2011-03-23T18:02:59Z")

</div>

Yes the client tag is the problem. You cannot reference client tags in the gateway script since they are only available in the client.

---

<div class="post-metadata">

**Author:** ![Viggy75](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@Viggy75](https://forum.inductiveautomation.com/u/Viggy75)\
**Post date:** [April 5, 2012, 3:41pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799/3 "2012-04-05T15:41:10Z")

</div>

I have more of a question than a problem.

Here is the background: I have a script that I’d like to run that changes line colours based on certain conditions, I’m thinking I’d only like to have this script execute when the line’s associated tag changes.

Now for my question: is it better to execute the tag change scripts at the client side or the gateway side? All of the tags that I’d be monitoring for change reside in the SQL database. I’d like to only have the script execute once rather than once per client.

I know I may have answered my own question but would like a more experienced opinion

Brian

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 5, 2012, 4:04pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799/4 "2012-04-05T16:04:23Z")

</div>

If you only want the script to run in one place you would use a Gateway Event Script. The gateway event scripts run on the gateway in one location even if a client is not open. The client scripts run on every single client that is open and if no client is open nothing runs.

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [April 5, 2012, 4:07pm UTC](https://forum.inductiveautomation.com/t/gateway-script/2799/5 "2012-04-05T16:07:59Z")

</div>

Unless I’m missing something big, I don’t know why you would use scripting at all. If you want to change a color based on a tag, simply bind the property using a tag binding. If you need something more complex, you could probably use an expression.

Again, I’m probably missing something, but overall, it’s easier to use binding rather than scripting when possible.

Regards,
