A new command line utility that ships with OS X Mountain Lion that prevents your Mac from falling asleep.
Handily, you can apply it to a specific command, like so
caffeinate longrunningcommand -x -y --zed
caffeinatewill keep your Mac awake until it’s finished.
Via Ask Different.