Depado
Depado

Reputation: 4931

Embedding a Bash shell in my Flask application?

I know this is kind of weird and not secure at all, but is there a way of displaying a bash shell with a remote control on the machine where the webapp is running ?
I would like to have a bash interpreter running directly in the webapplication in flask, does anyone knows how to do such a thing ?

Thanks a lot,
If my post wasn't clear enough just tell me and I will try to improve it.

Upvotes: 2

Views: 1365

Answers (1)

Paco
Paco

Reputation: 4708

You can create an interface that looks like you opened a new terminal. To do so, create a form, and everytime you hit Enter, you send this data (using jQuery.ajax for instance) to the server.

On the server side, use subprocess to run the commands you get from the server. You might need to parse this data (something like: my_string.split(' ')) in order to get the argument in a list. You can return the result of that command using: subprocess.check_output in a JSON data type to the client. With Javascript (and jQuery) you can now parse that data and display it wherever you want.

Upvotes: 1

Related Questions