Created
January 14, 2016 10:52
-
-
Save Franco-Poveda/9ad6705b2c71d64af7ff to your computer and use it in GitHub Desktop.
Simple script to execute a bash command via a http request just using the node native functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Listen incommig HTTP connection to '/' | |
| * and executes a arbitrary command to | |
| * the host stdout. | |
| * | |
| * Pogui (2016) | |
| * poguijuaz [at] gmail | |
| */ | |
| var http = require('http'), | |
| exec = require('child_process').exec; | |
| var cmd = '<your bash command>'; | |
| http.createServer(function (req, res) { | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| exec(cmd, function(err, stdout, stderr) {console.log(stdout)}); | |
| res.end('OK'); | |
| }).listen(9669); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment