Thursday, April 19, 2012

ttytter, perl and fortune

Ttytter is a fully fledged Twitter client written in Perl - it is operated in CLI only.. I love it.

I am not an avid Twitter user, though I try to be - so in order to increase my post statistics, I decided to write a little script that would post something clever everyday.
Enter the fortune game.. pretty much resident on most unix flavors.

I've written a small shellscript that looks like this:

while [ 1 ]
FOO=`/usr/games/fortune -a -s`
if [ ${#FOO} -lt 140 ]; then
        /usr/local/bin/ttytter -curl=/usr/local/bin/curl -status="$FOO"

It basically runs a while-loop -that finds a fortune with less than 140 characters (Twitter message limit), and then posts it to my Twitter account.
If the fortune found is more than 140 characters, it simple fetches another one.

I've added the script to run in cron(1) once a day..

Here's the result from today!

Mazel, mazel...


isomorphismes said...

Is there a difference between while [1] and while[ yes ]?

mich said...