# Using openURL in gateway script

**URL:** <https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400>\
**Category:** Ignition\
**Created:** [October 7, 2011, 1:56pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400 "2011-10-07T13:56:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex.ferrell](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@alex.ferrell](https://forum.inductiveautomation.com/u/alex.ferrell)\
**Post date:** [October 7, 2011, 1:56pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/1 "2011-10-07T13:56:25Z")

</div>

I have the following code in a gateway tag change script:

if event.newValue ==0:  
system.net.openURL(“file://D:\ISD files\Normal mode.bat”)  
else:  
system.net.openURL(“file://D:\ISD files\Backup mode.bat”)

When the script runs I get an error in the console something about not having the attribute “openURL”. Sorry I forgot to write down the exact error. When I try the openURL statement in a client tag change script or the script playground it works just fine (except the file can’t be found because it exists on the gateway).

---

<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:** [October 7, 2011, 3:10pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/2 "2011-10-07T15:10:13Z")

</div>

You can’t call the openURL function on the gateway since the function opens a web browser. It is meant for the client machine. What you want to use is system.util.execute:`if newValue.value == 0:
    system.util.execute(["D:\\ISD files\\Normal mode.bat"])
else:
    system.util.execute(["D:\\ISD files\\Backup mode.bat"])`

---

<div class="post-metadata">

**Author:** ![alex.ferrell](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@alex.ferrell](https://forum.inductiveautomation.com/u/alex.ferrell)\
**Post date:** [October 7, 2011, 3:12pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/3 "2011-10-07T15:12:17Z")

</div>

I figured it had to be something like that. Thank you.

---

<div class="post-metadata">

**Author:** ![alex.ferrell](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@alex.ferrell](https://forum.inductiveautomation.com/u/alex.ferrell)\
**Post date:** [October 7, 2011, 3:19pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/4 "2011-10-07T15:19:50Z")

</div>

I am getting a syntax error for that system.util.execute command string.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 7, 2011, 4:32pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/5 "2011-10-07T16:32:34Z")

</div>

“” is an escape character in Python. You need to use “\” to get a literal backslash.`system.util.execute(["D:\\ISD files\\Normal mode.bat"])`

---

<div class="post-metadata">

**Author:** ![alex.ferrell](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@alex.ferrell](https://forum.inductiveautomation.com/u/alex.ferrell)\
**Post date:** [October 7, 2011, 5:12pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/6 "2011-10-07T17:12:25Z")

</div>

I thought of that as well but it fails with the “\” as well. It appears the compiler automatically changes the “” to “\” anyway. I attached a screen shot of the syntax error.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d2be9e1300c79a3a88cc088cd3dbdeade99ebd47.png)

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [October 7, 2011, 5:59pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/7 "2011-10-07T17:59:30Z")

</div>

It looks like you are using spaces and a tab instead of two tabs on line 3 (and probably line 5 as well). If you remove all whitespace and replace it with tabs, it will work.

---

<div class="post-metadata">

**Author:** ![alex.ferrell](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@alex.ferrell](https://forum.inductiveautomation.com/u/alex.ferrell)\
**Post date:** [October 7, 2011, 6:01pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/8 "2011-10-07T18:01:45Z")

</div>

That was it. It must have something to do with the copy and paste from the code in the post. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![todd.be](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@todd.be](https://forum.inductiveautomation.com/u/todd.be)\
**Post date:** [October 7, 2011, 8:41pm UTC](https://forum.inductiveautomation.com/t/using-openurl-in-gateway-script/3400/9 "2011-10-07T20:41:29Z")

</div>

For reference, you can also use r"D:\ISD files\Normal mode.bat". The r refers to regex string literal and will not use the backslash escape. Only catch is that the last character cannot be a backslash (i.e r"D:\ISD files"). I didn’t verify this with jython so I could still be wrong but this is standard python behavior.
