Skip to content

Instantly share code, notes, and snippets.

@derinbay
Created March 14, 2018 10:26
Show Gist options
  • Save derinbay/d051b8548d468a7b7eb5b2b94d9619ec to your computer and use it in GitHub Desktop.
Save derinbay/d051b8548d468a7b7eb5b2b94d9619ec to your computer and use it in GitHub Desktop.
#!/bin/bash
#Usage:slackpost<token><channel><message>
#Enterthenameofyourslackhosthere-thethingthatappearsinyourURL:
#https://slackhost.slack.com/
slackhost=n11dev
token=$1
if[[$token==]]
then
echoNotokenspecified
exit1
fi
shift
channel=$1
if[[$channel==]]
then
echoNochannelspecified
exit1
fi
shift
text=$*
if[[$text==]]
then
echoNotextspecified
exit1
fi
#escapedText=$(echo$text|sed's//\/g'|seds/'/\'/g)
json={\channel\:\#$channel\\n\text\:\$escapedText\}
curl-s-dpayload=$jsonhttps://$slackhost.slack.com/services/hooks/incoming-webhook?token=$token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment