Skip to content

Instantly share code, notes, and snippets.

@rbocchinfuso
Created August 24, 2018 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbocchinfuso/f789cf19ba6ad90690c146e6328ed777 to your computer and use it in GitHub Desktop.
Save rbocchinfuso/f789cf19ba6ad90690c146e6328ed777 to your computer and use it in GitHub Desktop.
Simple Hubot CoffeeScript to fire other local commands
# Description:
# Runs a command on hubot
# TOTAL VIOLATION of any and all security!
#
# Commands:
# hubot cmd <command> - runs a command on hubot host
module.exports = (robot) ->
robot.respond /CMD (.*)$/i, (msg) ->
# console.log(msg)
@exec = require('child_process').exec
cmd = msg.match[1]
msg.send "Running [#{cmd}]..."
@exec cmd, (error, stdout, stderr) ->
if error
msg.send error
msg.send stderr
else
msg.send stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment