How do I execute a downloaded file?

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

I have a project that downloads an executable file from my server, and it needs to execute it. It won’t start, probably because it doesn’t have executable permissions, but how do I give the file these permissions from gdscript?

OS is Linux, Godot 3.2.3

:bust_in_silhouette: Reply From: deaton64


Maybe with the OS.execute method.


I’ve not tried it as I’m running Windows atm, but looks like it should work. You can chmod the file if you have permission to do so.

Something like:

var output = []
var exit_code = OS.execute("chmod", ["+x", "./filetochmod"], true, output)

I’ve just tested this on Ubuntu 20.04 and this worked:

OS.execute("chmod", ["+x", "/tmp/"], true)

I figured it out only minutes before this answer lol, and this is exactly what worked!

andersmmg | 2021-03-29 05:13