How to execute cmd commands through gdscript

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

Hello I am an intermediate godot user, I want to make a button to run a python script in the command prompt when it is pressed. I used OS.create_process and OS.execute but with no success. Any help will be greatly appreciated.

The python script also contains input functions so I will also need to use the terminal for inputs

I did exactly the same thing on this project. It’s Godot 3.5, but I’m pretty sure it doesn’t change much. Arguments are passed to OS.execute and received on Python’s os.argv.

Joel Gomes da Silva | 2023-05-26 13:46

:bust_in_silhouette: Reply From: CollCaz

Does this not work anymore?

I tried it but the cmd opens and freezes

Animesh | 2023-05-27 03:34

:bust_in_silhouette: Reply From: Joel Gomes da Silva

I did exactly the same thing on this project. It’s Godot 3.5, but I’m pretty sure it doesn’t change much. Arguments are passed to OS.execute and received on Python’s os.argv.

Yeah I tried it but I can’t figure it out, it simply doesn’t work.
I have a python file with the code:

a = int(input("Enter the length of password"))
...
print(password)

I just want godot to run the python file in command prompt. What arguments in the OS.execute() function should I give?

Animesh | 2023-05-29 08:16