 scanOne = (host,next)->
   command = 'sudo nmap -sS -sU ' + host + ' -P0 | awk \'$2=="open" {print $1}\' | sed \'s/\\/...//g\' | xargs echo -n'
   exec command, (error, stdout, stderr) ->
-    #MongoClient.connect 'mongodb://127.0.0.1:27017/test', (err, db) ->
-      #if err then throw err
-      #collection = db.collection 'ips'
     db.ips.update {ip: host}, {$set: {port: stdout.split ' '}}, {upsert:true}, (err, docs) ->
       if err then throw err
       console.log host

      console.log '...All jobs done'
      db.close()

#    q.on 'jobStart', (args) ->
#      console.log 'jobStart', args._jobId

#    q.on 'jobEnd', (args) ->
#      console.log 'jobEnd', args._jobId

    q.run()



##scanner.coffee
fs = require 'fs'
exec = require('child_process').exec
mongojs = require 'mongojs'
http = require 'http'
qjobs = require 'qjobs'
