How to make a remote command console


I am trying to make a command console from a website that when writing a command in the console (Windows) returns what is printed on the screen but in the same website, what I need is that it is interactive, that when pressing enter or some button returns the answer in the same dialog box and it is not necessary to redirect the page (as it would normally be in a form in php), I'm trying with MySQL and Python, basically entering the commands to the base of data and in python a query is made with an infinite cycle that returns the result of the execution in a variable to later update the table in MySQL with the result and display it in the website.

Python code

import subprocess
import MySQLdb

host = "localhost"
user_host = "root"
pass_host = ""
db_host = "myapp"

db = MySQLdb.connect(host, user_host, pass_host, db_host)
cursor = db.cursor()

while True:
    command = cursor.execute("SELECT console FROM prueba")
    if(command != ''):
        result = subprocess.check_output(command)
        cursor.execute("INSERT INTO console (command) VALUES (%s)", result)


margin: 10px;
padding: 10px;
width: 600px;
height: 500px;
border-radius: 5px 5px;
background-color: black;
color: green;
font-family:'Roboto Mono', monospace;
font-size: 16px;
resize: none;
font-weight: bold;

include ("php/conexion2.php");

<!DOCTYPE html>
	<link rel="stylesheet" type="text/css" href="bootstrap/css/console.css">

<div align="center">
    <textarea id="console" placeholder="Escriba un comando..."></textarea>


If you know any other way to do it I would like to know, I think this method is very tedious.

asked by Ciberstein 03.01.2019 в 16:19

0 answers