Skip to content

Instantly share code, notes, and snippets.

@drbobbeaty
Created October 9, 2012 21:45
Show Gist options
  • Save drbobbeaty/3861655 to your computer and use it in GitHub Desktop.
Save drbobbeaty/3861655 to your computer and use it in GitHub Desktop.
Bash script to send stdin to a Campfire room using curl API
#!/bin/bash
#
# This script takes stdin and sends it to the QuantumLead Campfire room as
# Canadarm. This can take an optional '-p' argument so that the stdin will
# be treated as a "paste" and go in as a fix-edwidth font paste. Otherwise,
# it'll appear as a simple proportional font "message"
#
# Let's make sure all the commands we need are accessible to us...
export PATH="/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:$HOME/bin:$PATH"
# start with the AuthToken for Canadarm and the QuantumLead room
token="969baac86c42c23ff715f0000000000000000000:X"
room="511111"
# see if we have the option to treat it as a 'paste'
paste=''
for arg in "$@"; do
case "$arg" in
-p)
paste='<type>PasteMessage</type>'
;;
esac
done
# grab all of stdin - unless there is nothing, and put in something
body=$(cat)
if [ ${#body} -eq 0 ]; then
body='empty'
fi
# now we can build up the curl command and ship it out
msg="<message><body>${body}</body>$paste</message>"
url="https://thepoint.campfirenow.com/room/$room/speak.xml"
ans=`curl -u "$token" -H 'Content-type: application/xml' -d "$msg" $url 2>/dev/null | grep 'starred type'`
if [ ${#ans} -eq 0 ]; then
echo 'Bad news - sending to campfire failed!'
fi
echo "${body}"
@Trickish0
Copy link

hi can you help me pls

@drbobbeaty
Copy link
Author

What's the problem?... I haven't used Campfire - from the folks at 37signals in many years, but I'll help if I can.

@Trickish0
Copy link

Trickish0 commented Oct 3, 2022 via email

@drbobbeaty
Copy link
Author

Sorry... there is no need for "ASIC hub"... this is just Bash and curl... that's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment