V
V
Valery Ivanov2015-01-13 18:23:13
PHP
Valery Ivanov, 2015-01-13 18:23:13

How to display the console on the site?

I need to bring the console from ubuntu to the site, I don’t know how. In order for commands to be sent, it is necessary that the user can do something only with what is already running in the desired screen session. How can I do that? It is impossible for the user to close the screen and go further in the console, only his screen.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg Prilepa, 2015-01-13
@OAPrilepa

I think you can make a form with a textarea on the frontend, style it for the console.
On js, catch pressing enter and take the last line.
Send it with ajax to the backend.
And there already execute (php exec) and return a response.
Which on js (ajax callback) to insert further into the textarea.

I
IceJOKER, 2015-01-13
@IceJOKER

stackoverflow.com/questions/10598561/using-php-to-...
stackoverflow.com/questions/6685889/how-to-execute... ?

A
Andrey Galkin, 2015-01-13
@socengel

Wrote offhand according to the documentation. If so, I think you'll understand.
If you need to send it right away, you can pass the return of such a function through nl2br ()

function exec_output( $cmd, $return_array = FALSE) 
{
    $console = array();
    exec($cmd, $console);

    if ( ! $return_array )
    {
        return implode(PHP_EOL, $console);
    }
    else {
        return $console;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question