This “bot” consists of three files, and a cronjob.
- a plain text file containing all of the poetry of Matthew Arnold.
- a config file bearing only the current line number
- the bash script that reads the line and sends the “dent” (update) to status.net
I just have this in my crontab
0 * * * * /path/to/mattUP
This runs the script every hour.
Here's the script (which I have named “mattUP”):
#!/bin/bash # dent the entire poetic works of Matthew Arnold # by tony baldwin | www.tonybaldwin.me # what line are we on? read from the config file source mattline.cfg # grab the line from the text file myline="$line"p ud=$(sed -n $myline mattarnoldpoems.txt) # send the update curl -u mattarnold:********* -d "status=$ud&source=mattBot" \ http://status.farcebork.com/api/statuses/update.xml # rewrite the config file, incrementing the line number by 1 # the poetry file has 14222 lines, so, when we reach 14222 # we will start all over, resetting to line 1. if [[ $myline = 14222 ]]; then newline=1 else newline=$((line + 1)) fi echo line=$newline > mattline.cfg #done exit
The mattline.cfg file is very simple. It looks like this:
initially, and then each time the script is run, it increments the value by 1, and rewrites the file.
And the poetry file, mattarnoldpoems.txt, is just a simple, plain text file, with all of Matthew Arnold's poetic works, line by line, with no empty lines.
Download mattbot: http://tonybaldwin.me/downloads/mattbot.tar.gz
O, si quieres, se puede hacer el mismo con la poesia de Pablo Neruda.
Or, maybe you'd like to dent or tweet The Constitution of the United States of America.
If you set up any of these, or something else cool, be sure to comment below and let me know all about it.