# Subprocess & system.util.execute

**URL:** <https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329>\
**Category:** General Discussion\
**Created:** [April 7, 2021, 7:52am UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329 "2021-04-07T07:52:05Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2024, 12:04pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/23 "2024-09-09T12:04:23Z")

</div>

> [@samer\_samy](#):
>
> a web launched ignition client

Do you mean Perspective? Or do you mean the legacy WebStart technology in pre-v8 Ignition?

If Perspective, you simply cannot run any code on the local computer or work with the local computer's filesystem. Full stop.

If Vision, whether via JNLP or a local launcher, you can--client jython scripts that call `system.util.execute()` will run in the local client system.

In either case, a gateway script can run an external script in the gateway filesystem in the gateway environment.

---

<div class="post-metadata">

**Author:** ![Samer\_Samy1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy1/32/52910_2.png) [@Samer\_Samy1](https://forum.inductiveautomation.com/u/Samer_Samy1)\
**Post date:** [September 9, 2024, 12:28pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/24 "2024-09-09T12:28:50Z")

</div>

Thanks pturmel for usual support.

Yes I mean perspective ,thanks for confirming that I can not access files in gateway PC from perspective opened in client PC .

Regards,

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2024, 12:42pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/25 "2024-09-09T12:42:40Z")

</div>

Perspective scripts run in the gateway, so of course can access gateway files (where the gateway service has filesystem permissions).

---

<div class="post-metadata">

**Author:** ![Samer\_Samy1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy1/32/52910_2.png) [@Samer\_Samy1](https://forum.inductiveautomation.com/u/Samer_Samy1)\
**Post date:** [September 19, 2024, 12:47pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/26 "2024-09-19T12:47:32Z")

</div>

Hi Pturmel,

Till now I did not solve this challenge .

At the beginning I was testing my gateway's code inside my designer script console and files opened in my designer machine and runs correctly.

I copied my py code to my gateway's machine and trying to open using same code after running it in perspective session and can not open

I have a button's click event :

```
system.util.sendRequest("MegaMain", "flaskStart", timeoutSec = 120)

```

MegaMain is my project's name ,flaskStart is my gateway's event.

inside flaskStart ,my dedicated gateway's event :

```
import subprocess
import os.path

# Create the command
    command = ["C:\Program Files\Git\git-bash.exe", "C:\ML\ML_MENABEV\launch.sh"]

# Use subprocess to run the command
process = subprocess.Popen(command)

```

I am trying now to test some simple codes inside gateway's event like :  
system.util.execute(['notepad.exe', 'C:\Program Files\Inductive Automation\Ignition\Notice.txt'])

to check my gateway's response and for example ,this text file is not opened in my gateway's machine.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 19, 2024, 1:06pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/27 "2024-09-19T13:06:02Z")

</div>

Ignition runs as a service and Windows does not allow services to start new processes that have user interfaces.

To be clear, `system.util.execute` does work when run in the context of the Ignition Gateway - you just can't expect anything with a UI to open and be visible.

---

<div class="post-metadata">

**Author:** ![Samer\_Samy1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy1/32/52910_2.png) [@Samer\_Samy1](https://forum.inductiveautomation.com/u/Samer_Samy1)\
**Post date:** [September 19, 2024, 4:25pm UTC](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329/28 "2024-09-19T16:25:03Z")

</div>

Thanks Kevin , I found a way to run py code in the gateway , by creating new task scheduler that run the bash file in gateway machine ,and call it from perspective session as below :

```
   import system

# Define the name of the scheduled task
task_name = "RunBashScript"

# Define the command to run the scheduled task
command = ['cmd.exe', '/c', 'schtasks /run /tn "{}"'.format(task_name)]

# Execute the command
system.util.execute(command)

```

[Previous page](https://forum.inductiveautomation.com/t/subprocess-system-util-execute/45329.md?page=1)
