05401, 05403, 05446, 05462, 05482, 05673, 05701, 37signals, 40hz, 2008, 2010, aardman animations, ac propulsion, adium, ads, aim, airport, al franken, algorithm, amazon, animation, apache, apple, applescript, architecture, archive, art, article id, asterisk, at&t, atom, automobile, away message, backpack, badge, barack obama, basecamp, bash, beos, bernie sanders, bicycling, billboard, blacklisting, blog, blogroll, blogzot, bluetooth, blunt, bluray, book, bookmarklet, bot-net, brad bird, browser, btv, bug, build, bungie, bunny, burlington, call of duty, camera, camping, can-spam, cars, centralized, channel camp, chocolate, classic, classic mac workshop, clothing, cms, collection, color classic, comedy, comedy central, comic, computer, concert, conversion, cookbook, corrosion, cowards way out, crack, crashing, creature comforts, criticism, daring fireball, darwin, dashboard, david byrne, dcl, death, delicious, derbi, design, development, digg, dilemma, discussion, disney, domain, download, drivers, dvd, dynetk, e-mail, e3, easter, ebox, eckhart, eckhart köppen, eckhart koppen, eddie izzard, edward gorey, einstein, election, electric motorcycle, electric motorsport, electric vehicle, electronics research laboratory, elmo, emate, emulator, encryption, environment, environmental impact, erin mckeown, escale, exploit, express 530t, expressionengine, feature, feed, feedburner, filtering, finance, firmware, fixdavsvn, flickr, flynn center, focus, font, food, ford, for sale, free, freeverse, freezing, fresh air, frog design, front row, fusion, games, gears of war, geek, geek technique, geocities, gmail, google, gpr, grammar, grant hutchinson, graylisting, gtd, hack, haiku, halo, hayao miyazaki, health, higher ground, highrise, hiking, hiroshi noguchi, history, hope, hotspot, html, html5, hulu, humor, hybrid, hybrid technologies, hypercard, intel, internet, interview, ipad, iphone, ipod touch, isao takahata, itunes, jabber, japan, javascript, jetblue, jfk, john gruber, john oliver, jon stewart, kid koala, launchd, layover, leopard, liberal, long trail, lorem ipsum, mac, macbook pro, macworld, maczot, magazine, mail, maine, makkintosshu, marathon, marketing, mark hoekstra, matthias melcher, media, mesagepad, messagepad, microbus, microsoft, mobileme, model s, modern warfare, money, monitoring, moon river, motorola, movie, movies, mrtg, multitasking, music, mwsf07, mystic, nascar, ncx, nda, netflix, network, newton, newton os, newton press, newtontalk, newton x press, nick park, nitch, npr, on point, openpbx, open source, operation ivy, optimization, organic, os 8, os9, osheaga, osx, os x, owc, package, palm, password, paul guyot, pbx, pdf, pesticides, photography, pico card, pilot, pixar, playstation, plist, plug-in, pod jungle, politics, productivity, ps3, psp, pump-and-dump, quicksilver, racism, rack-n-roll, radio, ratatouille, rebooting, recycling, remake, required reading, restoration, retrochallenge, review, roadster, room without a window, rss, scion, screencast, script, search, security, server, sesame street, seven days, shame, shelburne, shelburne museum, shirt, shoppinging cart, simon bell, small dog electronics, snow leopard, social, software, solution, sony, spam, spam haus, startup item, statistics, status, stefano paris, stephen colbert, steve jobs, steven colbert, steven frank, studio 360, studio ghibli, subethaedit, subversion, swiss, sync, syndication, sysmon, tablet, tags, tax, technorati, ted talk, television, terry gross, tesla motors, textpattern, the colbert report, the daily show, the flaming lips, the gashleycrumb tinies, the radiator, the world, times argus, titles, tkip, todd kollins, tom gage, trailer, travel, tree, trends, troubleshooting, twitter, typography, tzero, unicel, unna, update, upgrade, url title, user interface, v710, venue, verizon wireless, vermont, victor rehorst, video, virtualization, vmware, volkswagen, volvo 122, vpr, vw, wait wait don't tell me, wall-e, wallace & gromit, wavelan, web, web 2.0, webkit, web site, whitepaper, wifi, wikipedia, windows, winter warm-up, wireless, wpa, writing, wwdc, wwnc, xbox 360, xbox live, xhtml, yahoo, ze frank, zero emission
Articles Tagged "cowards-way-out":
Automating Countdown Tweets with Bash ¬
2009-11-02
Modern Warfare 2 will be out in a few days, so I felt @cowardswayout should count down to the release day. I could spend a few minutes at some point during each of the next few days—assuming I can remember to—posting a nearly-the-same message to Twitter or I could automate it. Yeah, better automate.
In trying to keep my bash-fu hightened, I tossed together the following bash script:
#!/bin/bash# # mw2_countdown # # Post countdown to Modern Warfare 2 release to Twitter every day #release_year=2009 release_month=11 release_day=10 year=10#$(date +%Y) month=10#$(date +%m) day=10#$(date +%d) username='cowardswayout' password='somethingiwontleakhere'if (( $release_year == $year && $release_month == $month && $day <= $release_day )); then if (( $day == $release_day )); then printf -v message "Modern Warfare 2 (http://bit.ly/dQMPz) is out! Go get your copy!" else printf -v message "Modern Warfare 2 (http://bit.ly/dQMPz) in %s..." $(( $release_day - $day )) fi curl -u $username:$password -d status="$message" http://twitter.com/statuses/update.xml fi
Since I host with Mac OS X Server and am anal about doing things “The Mac Way”, I whipped up a launchd job to run it every morning at 1am:
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.cowardswayout.mw2_countdown</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/mw2_countdown</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>1</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
As you can see, I installed the bash script in /usr/local/bin/mw2_countdown and the launchd job went in /Library/LaunchDaemons/com.cowardswayout.mw2_countdown.plist.
I changed the permissions so that only root has read/execute access to the bash script, since the Twitter account password is stored in plain text:
sudo chmod 700 /usr/local/bin/mw2_countdown
And loaded the launchd job:
sudo launchctl load /Library/LaunchDaemons/com.cowardswayout.mw2_countdown.plist
Now I only have to remember to remove the bash script and launchd job sometime after 11/10/09. Naturally, this script can be easily tailored to your own needs.
Update: I’ve updated the script to prepend 10# to each call like $(date +%y) to force it to be evaluated as base 10 and also switched from using test (square brackets) to using the correct arithmetic evaluations (double parentheses).

