Running OS.Execute on linux/retropie

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Teethree89

Hello, I am running a simple self-closing action via ui_input spacebar, using OS.execute, and was wondering if my syntax was correct to send this command to the terminal/console of the OS:

ps -ef | awk '/godot-engine/ {print $2}' | xargs kill

the way I have it (tested that the input works, and it does, via a pop-up sprite visible=true on spacebar press) is as follows:

func _on_DisplayAlert_pressed():
var output = []
#var Pvariables = "-ef | awk '/tester/ {print $2}' | xargs kill"
OS.execute("ps", ["-ef", "|", "awk", "'/tester/ {print $2}'", "|", "xargs", "kill"], true, output)
#OS.alert(String(output))

the Pvariables was a test to see if it needed to be one string, but the action seems to be doing nothing, I tried it on a windows OS with CD and START commands and it operated after export, what could I be doing wrong?

Thank you!

:bust_in_silhouette: Reply From: Wakatta

So you’re asking a game engine to do complex tasks with unrelated syntax … hmm nothing can possibly go wrong here and debugging won’t be a nightmare with the more you will later need to add.

Suggestion

Use scripts for such tasks with the native console

#Example
OS.execute("bash", ["my_complicated.sh", "param1"])

#Another Example
OS.execute("cmd", ["my_complicated.bat", "param2"])

#Another other Example
OS.execute("python", ["my_complicated.py", "param3"])