Somehow, via Isaac Truett’s repost of a Robert Konigsberg
I just stumbled upon today, I thought it was worth my time to take Rob’s creepy
one-line Mac OS X shell script to the next little level. See, when I ran the
say -v ? command in that script, I found the output…amusing. But, since it’s
a pain to parse strings into multiple fields in a shell loop, I dropped down to
Python to do the dirty deed.
I call it
creepy.py. Run it with the lights on, folks.
#! /usr/bin/env python import os import re import subprocess for l in subprocess.Popen(['say', '-v', '?'], stdout=subprocess.PIPE).communicate().split('\n'): if not l: break l = re.sub(' +', '|', l) name, _, quote = [s.strip('# ') for s in l.split('|')] print "%s: %s" % (name, quote) subprocess.call('say -v "%s" "My name is %s. %s"' % (name, name, quote), shell=True)