Calling Python scripts w/ arguments on the backend via plugin?

Let’s get this out of the way: I’m NOT a front-end guy at all. That said, I’ve written a Python script that runs on the same instance as my Discourse install, and upon execution certain methods take in arguments from the user. It works exactly as intended when run from the terminal. I need to figure out how to expose this to mods via plugin, where they can add the expected input in text fields and hit some kind of ‘execute’ button which in turn runs the script with the provided arguments. I have no idea where to begin. If someone could point me in the right direction, that’d be grand. Is it as simple as starting with the guide on writing plugins? I did go through this and I don’t remember that anything immediately jumped out as to being what I was looking for, but if I just need to go over it again and that’s the best place to start, please let me know! Thanks!


You can use Running external commands with Open3 - makandra dev
to call the command line in Ruby and plugins.

I use it here in my Discourse Frotz (Interactive Fiction) plugin: to interact with the terminal.

But if you are going that far you might consider writing native Ruby all the way. It’s a very pleasant language.


Thanks so much, really appreciate your assistance!

1 Like