Skip to content

Instantly share code, notes, and snippets.

@JeffreyVdb
Last active August 29, 2015 14:03
Show Gist options
  • Save JeffreyVdb/9f7b351df56764e8216c to your computer and use it in GitHub Desktop.
Save JeffreyVdb/9f7b351df56764e8216c to your computer and use it in GitHub Desktop.
'require strict';
var http = require('http'),
url = require('url'),
fs = require('fs'),
util = require('util'),
exec = require('child_process').exec,
sh = require('execSync');
http.createServer(function (req, res) {
var urlParts = url.parse(req.url, true),
query = urlParts.query || {},
numPasswords = (query.passwords && parseInt(query.passwords)) || 6,
len = (query.len && parseInt(query.len)) || 24,
cmdLine = '/bin/bash /usr/local/bin/mkpassword ' + len + ' ' + numPasswords;
util.puts(cmdLine);
exec(cmdLine, function (err, stdout, stderr) {
if (err) {
throw err;
}
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(stdout);
});
}).listen(9615);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment