From b694bd511ceccd00d4a4c98f36f910d5fc5f79c4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 1 Jun 2017 19:43:48 -0400 Subject: email text --- lib/awprint/index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/awprint/index.js b/lib/awprint/index.js index dec43fd..f379ad8 100644 --- a/lib/awprint/index.js +++ b/lib/awprint/index.js @@ -4,6 +4,8 @@ var path = require('path') mongoose.Promise = require('bluebird') var socketIO = require('socket.io') +var exec = require('child_process').exec + function AWPrint (options) { if (!(this instanceof AWPrint)) return new AWPrint(options) @@ -66,10 +68,18 @@ function AWPrint (options) { router.post('/print', bodyParser.json({}), function (req, res) { res.sendStatus(200) - Print.update({ _id: req.body._id }, { printed: true, }).then( (req) => { - // send a websocket message? + Print.findOne({ _id: req.body._id }).then( (job) => { + job.printed = true + + var cmd = 'curl ' + job.url + ' | lpr -P ARMORYHPM553' + console.log(cmd) + exec(cmd, function(error, stdout, stderr) { + console.log('ok') + }) + + return job.save() }).catch( (err) => { - // idk + console.log('error saving?') }) }) -- cgit v1.2.3-70-g09d2