Created
March 3, 2017 08:58
-
-
Save linktohack/2f04f48c946af2abbfd190b58b1ce03f to your computer and use it in GitHub Desktop.
List uploaded terminals
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
const http = require('http'); | |
const exec = require('child_process').exec; | |
const hostname = '0.0.0.0'; | |
const port = 3000; | |
const server = http.createServer((req, res) => { | |
exec('ls /home/scamark | sed s"/-2017.*//" | sort | uniq', (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'text/plain'); | |
res.end('Hello World\n'); | |
return; | |
} | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'text/plain'); | |
res.end(stdout); | |
}); | |
}); | |
server.listen(port, hostname, () => { | |
console.log(`Server running at http://${hostname}:${port}/`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment