Using openURL in gateway script

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

if event.newValue ==0:“file://D:\ISD files\Normal mode.bat”)
else:“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).

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"])

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

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

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

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.

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.

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

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.