# System.util.execute error

**URL:** <https://forum.inductiveautomation.com/t/system-util-execute-error/45267>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 5, 2021, 4:22pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267 "2021-04-05T16:22:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![KingT8](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@KingT8](https://forum.inductiveautomation.com/u/KingT8)\
**Post date:** [April 5, 2021, 4:22pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/1 "2021-04-05T16:22:05Z")

</div>

Hello,

I am trying to script a check box to find the correct text file using system.util.execute. I have two errors. Here is the code I have for the ‘property change’ event handler.

| | | | val = event.source.parent.getComponent(‘StationType\_Lbl’).text |
| --- | --- | --- | --- |
| | | | system.util.execute(‘C:\Printing Templates’’ + val + ‘.txt’) |

If I don’t have the second ’ after Templates\ is throws the error ‘no viable alternate at input’ like it doesn’t close the end of the string.

The second is when I run the above code it gives this error:  
Traceback (most recent call last):  
File “event:propertyChange”, line 13, in   
TypeError: execute(): 1st arg can’t be coerced to String[]

Thank you for any help that can be provided.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 5, 2021, 4:29pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/2 "2021-04-05T16:29:47Z")

</div>

What is the content of `val`?

How’s this work

```auto
val = event.source.parent.getComponent(‘StationType_Lbl’).text
execute_string = "C:\Printing Templates%s.txt"%(val)
system.util.execute(execute_string)

```

Can you show your full script? You are just expecting system.util.execute to open the text file correct?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 5, 2021, 4:33pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/3 "2021-04-05T16:33:14Z")

</div>

You have a few issues here.

1. The “\” character is the escape character in python and jython by extension
2. `system.util.execute()` expects a list of strings, where the first string is the command, and the following strings are any arguments

As can be seen in the example found in the [manual](https://docs.inductiveautomation.com/display/DOC81/system.util.execute) your code will need to look something like this:

```auto
val = event.source.parent.getComponent('Station Type_Lbl').text
system.util.execute(['notepad.exe','C:\\Printing Templates' + val + '.txt'])

```

That can be made a bit more pythonic if you use string substitution. Like so:

```auto
val = event.source.parent.getComponent('Station Type_Lbl').text
system.util.execute(['notepad.exe','C:\\Printing Template%s.txt' % (val)])
```

---

<div class="post-metadata">

**Author:** ![KingT8](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@KingT8](https://forum.inductiveautomation.com/u/KingT8)\
**Post date:** [April 5, 2021, 4:38pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/4 "2021-04-05T16:38:17Z")

</div>

Thank you for the reply, the value of ‘val’ is the type of station the user is currently on. There is a corresponding text file with it in a folder, the text file has zebra printing language code in it (Model, newDate, Printer1IP are all variables inside the zpl code).

Here is the full script with your code input into it.

Count = 0

if event.source.selected is True:  
Count = Count + 1  
if event.source.parent.getComponent(‘PrinterAActive’).selected is True and event.source.selected is True:  
if Count == 1:  
Count = Count + 1  
Model = event.source.parent.getComponent(‘Dropdown’).selectedStringValue  
date = system.date.now()  
newDate = system.date.format(date, “MM/dd/yyyy HH:mm:ss”)  
Printer1IP = event.source.parent.getComponent(‘Printer1IP’).text  
val = event.source.parent.getComponent(‘StationType\_Lbl’).text  
execute\_string = “C:\Printing Templates%s.txt”%(val)  
system.util.execute(execute\_string)

```
		if Count != 1:
			Count = 0
			event.source.selected = False

```

else:  
Count = 0

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 5, 2021, 4:39pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/5 "2021-04-05T16:39:19Z")

</div>

Use triple backticks at the beginning and end of your code to format it

```

```auto
like this

```

```

---

<div class="post-metadata">

**Author:** ![KingT8](https://avatars.discourse-cdn.com/v4/letter/k/58f4c7/32.png) [@KingT8](https://forum.inductiveautomation.com/u/KingT8)\
**Post date:** [April 5, 2021, 4:43pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-error/45267/6 "2021-04-05T16:43:20Z")

</div>

Awesome, thank you so much this is exactly what I wanted. Thank you also @bkarabinchak.psi for your help as well.
