Steven Wright Aphorisms
For fun today I learned how to run a bash script from PHP, and implemented everybody’s favorite command line utility: fortune! The script takes advantage of php’s exec()
command, and ended up looking something like this:
<?php
exec ("/opt/local/bin/fortune -s", $lines_of_output, $error_code);
if (!$error_code) {
foreach ($lines_of_output as $line) {
print $line."\n";
}
} else {
print "script failed with exit code $error_code, see http://tldp.org/LDP/abs/html/exitcodes.html";
}
?>
Check out the two beta versions I’ve created here (Hit refresh in your browser to get a new fortune).
These are meant to be part of a larger project intended to expose these quotes via RSS to incorporate them into some dynamically created “signature” lines, which is part of some new Gmail functionality available from Google Labs.