CLI StatusNet

Update

Script for posting to statusnet with curl.

#!/bin/bash
 
# post to statusnet
 
# if you did not enter text for update, the script asks for it
 
if [[ $(echo $*) ]]; then
 	ud="$*"
 else
	read -p "Enter your update text: " ud
fi
 
if [[ ${#ud} -gt 500 ]]; then
	echo "FAIL!  Too much, d00d...you talk too damned much..."
	exit
fi
 
# and this is the curl command that sends the update to the server
if [[ $(curl -u USERNAME:PASSWORD -d "status=$ud&source=Parsnip by Tony Baldwin" http://YOURSTATUSNETSITE.url/api/statuses/update.xml | grep error) ]]; then
	echo "Error"
else
	echo "Posted to Parlementum!"
fi
 
echo $ud
 
read -p "Shall we have a look in your a browser now? (y/n): " op
 
if [ $op = "y" ]; then
	xdg-open http://YOURSTATUSNETSITE.url/USERNAME
fi
 
 
exit

Clearly, you change “USERNAME:PASSWORD” to your username and password and “YOURSTATUSNETSITE.url” to the url for your statusnet installation. For instance, for me, that would be http://free-haven.org/status/

Read One Timeline

Script for reading back updates from one person:
(I use identi.ca as an example here, but this will work with any statusnet installation. Just change the url, username, password, of course).

#!/bin/bash
 
# read identi.ca timeline for person
if [[ ! $* ]]; then 
	read -p "Whose updates would you like to read? " dude
else
	dude=$*
fi
echo ----------------------------------------------------------
echo dents from $dude
if [ $dude = all ]; then
 
	echo ----------------------------------------------------------
	echo public dents
	echo ----------------------------------------------------------
	curl -u USERNAME:PASSWORD -s "identi.ca/api/statuses/public_timeline.xml" | egrep 'screen_name' | sed -ne '{s/<[^>]*>//g;s/^[ \t]*//;p}' > snames
	curl -u USERNAME:PASSWORD -s "identi.ca/api/statuses/public_timeline.xml" | egrep 'text' | sed -ne '{s/<[^>]*>//g;s/^[ \t]*//;p}' > ups
	sed -e 's/^/\n/g' ups > upd
	sed -e 's/$/\ ----->\ /g' snames > sns
	rm ups
	rm snames
	paste sns upd > desedents
	rm sns
	rm upd
	cat desedents
	rm desedents
	echo ----------------------------------------------------------
else
 
	 echo ----------------------------------------------------------
	 curl -s "identi.ca/$dude" | sed -ne '/entry-content/{s/<[^>]*>//g;s/^[ \t]*//;p}'
	 echo ----------------------------------------------------------
 fi
 exit

Public Timeline

Read back the public timeline from a statusnet site. This will keep reading back the timeline every 30 seconds.

Again, using identi.ca only as an example.

#!/bin/bash
 
# read identi.ca timeline for person
 
while [ 1 -lt 2 ]; do
	clear
	echo ----------------------------------------------------------
	echo public dents
	echo ----------------------------------------------------------
	curl -u USERNAME:PASSWORD -s "identi.ca/api/statuses/public_timeline.xml" | egrep 'screen_name' | sed -ne '{s/<[^>]*>//g;s/^[ \t]*//;p}' > snames
	curl -u USERNAME:PASSWORD -s "identi.ca/api/statuses/public_timeline.xml" | egrep 'text' | sed -ne '{s/<[^>]*>//g;s/^[ \t]*//;p}' > ups
	sed -e 's/^/\n/g' ups > upd
	sed -e 's/$/\ ----->\ /g' snames > sns
	rm ups
	rm snames
	paste sns upd > desedents
	rm sns
	rm upd
	cat desedents
	rm desedents
	echo ----------------------------------------------------------
	sleep 30 # you can make it update more frequently, by lowering this number, or less frequently by increasing it.
done
 exit

There may be better ways to do any of these. Know one? Post it on the CLI Status talk page.

:)

tonybaldwin 2012.01.03.22.05


~~DISQUS~~