Skip to content

Instantly share code, notes, and snippets.

@linktohack
Created March 3, 2017 08:58
Show Gist options
  • Save linktohack/2f04f48c946af2abbfd190b58b1ce03f to your computer and use it in GitHub Desktop.
Save linktohack/2f04f48c946af2abbfd190b58b1ce03f to your computer and use it in GitHub Desktop.
List uploaded terminals
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