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 26 |
const { exec } = require('child_process'); var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/html"}); // Comando que quieres ejecutar const comando = 'powershell Get-Date'; // 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; } response.write(stdout); response.end(); }); }).listen(8888); |