Skip to content

Instantly share code, notes, and snippets.

@rilian
Forked from edderrd/slackpost
Created February 20, 2018 14:08
Show Gist options
  • Save rilian/c90a0c5a93a998d9f9d36c6f741e1399 to your computer and use it in GitHub Desktop.
Save rilian/c90a0c5a93a998d9f9d36c6f741e1399 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: slackpost <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
webhook=PUT_YOUR_HOST_HERE
shift
text=$*
if [[ $text == "" ]]
then
echo "No text specified"
exit 1
fi
escapedText=$(echo $text | sed 's/"/\"/g' | sed "s/'/\'/g" )
json="{\"text\": \"$escapedText\"}"
curl -s -d "payload=$json" "$webhook"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment