Last active
August 29, 2015 14:03
-
-
Save JeffreyVdb/9f7b351df56764e8216c to your computer and use it in GitHub Desktop.
This file contains 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
'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