How to Run the Hacks
The programmatic hacks in this book run either on the command line (that’s Terminal for Mac OS X folk, DOS command window for Windows users) or as CGI (that’s “common gateway interface”) scripts—dynamic pages living on your web site, accessed through your web browser.
Command-Line Scripts
Running a hack on the command line invariably involves the following steps:
Type the program into a garden-variety text editor: Notepad on Windows, TextEdit on Mac OS X, vi or Emacs on Unix/Linux, or anything else of the sort. Save the file as directed—usually as scriptname.pl (the pl bit stands for Perl, the predominant programming language used in Yahoo! Hacks).
Alternately, you can download the code for all of the hacks online at http://www.oreilly.com/catalog/yahoohks, where there is a ZIP archive containing individual scripts saved as text files.
Get to the command line on your computer or remote server. In Mac OS X, launch the Terminal (Applications → Utilities → Terminal). In Windows, click the Start button, select Run…, type
command, and hit the Enter/Return key on your keyboard. In Unix…well, we’ll just assume you know how to get to the command line.Navigate to where you saved the script at hand. This varies from operating system to operating system, but usually involves something like
cd~/Desktop(that’s your Desktop on the Mac).Invoke the script by running the programming language’s interpreter (e.g., Perl) and feeding it the script (e.g., scriptname.pl) like so:
$