Hey folks, What am I saying, is it possible to execute command on server via UI from client-side with few lines of code?
Let me tell you.
Make your own UI for enter command and send that command to server with suitable method and request.(use fetch, axios, etc.)
Make a basic server with your favourite libraries, now add one another library with name
execa is a js library for execute
.exe file with one line of code.
// your code .... const execa = require('execa') let output = execa.sync(command).stdout // pass your command as a args // your code ....
Now send this output in res and you can get the output of terminal.
you can't execute all command, because
execa is execute only one line command and then close the cmd. When you run command,
execa open new cmd and execute command, then close cmd. So your 'cd dir' command run successfully but cmd closed and next time open new cmd, so we can get old path and
cd dir goes vain.