Answer the question
In order to leave comments, you need to log in
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
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.
stackoverflow.com/questions/10598561/using-php-to-...
stackoverflow.com/questions/6685889/how-to-execute... ?
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 questionAsk a Question
731 491 924 answers to any question