1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
const { exec } = require('child_process'); var http = require("http"); // Comando que quieres ejecutar const comando = 'ps'; // Ejecutar el comando exec(comando, (error, stdout, stderr) => { if (error) { console.error(`Error al ejecutar el comando: ${error.message}`); return; } if (stderr) { console.error(`Error en la salida estándar del comando: ${stderr}`); return; } http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/html"}); response.write(stdout); response.end(); }).listen(8888); }); |