Created
October 9, 2012 21:45
-
-
Save drbobbeaty/3861655 to your computer and use it in GitHub Desktop.
Bash script to send stdin to a Campfire room using curl API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
What's the problem?... I haven't used Campfire - from the folks at 37signals in many years, but I'll help if I can.
I can't install ASIC hub
Dne po 3. 10. 2022 18:51 uživatel Bob Beaty ***@***.***>
napsal:
… ***@***.**** commented on this gist.
------------------------------
What's the problem?... I haven't used Campfire - from the folks at
37signals in many years, but I'll help if I can.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/3861655#gistcomment-4323142>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3M6GC3JJ25NALF36RFZMO3WBMFHJANCNFSM6AAAAAAQ3YWLMA>
.
You are receiving this because you commented.Message ID:
***@***.***>
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
hi can you help me pls