Prevent sleep in Mac OSX 10.8 when Igor is crunching data

The newest version of OSX will go to sleep even when Igor (or other processes) are in full flow. It appears that the new OS no longer does its own surveying to decide if it's safe to go to sleep but instead requires a "power assertion" from applications to stay awake (at least, that's my understanding from a limited comprehension of the results of a web search for "mountain lion power assertion sleep").

I realize that there are work-arounds from disabling sleep entirely in System Preferences to installing other programs and scripts, but it would be nice to be able to leave a large problem running overnight or longer and let the system power down when it's done. I realize that it's a case of Apple moving the goalposts (again?) which I imagine does little to engender affection in developers, but if the solution is not serious, it would be a great functionality to get back. Thanks!
You could caffeinate Igor Pro to prevent the system from sleeping as long as Igor is active. Granted it would be best to have Igor invoke an assertion to prevent sleep only during function execution or other similar actions, but it is still an option. To do this, launch Igor from the Terminal with the following command (you may have to alter the path according to your installation):

caffeinate /Applications/Igor\ Pro\ 6.2\ Folder/Igor\ Pro.app/Contents/MacOS/Igor\ Pro

You can create a small shell script with this for easier access, or use Automator and its "Run Shell Script" action to create a small launcher that will do this.

You could also set up an Igor hook that runs the Igor "ExecuteScriptText" command at launch, and then have this command run a "do shell script" routine that will invoke the "pmset noidle" Terminal command, which will prevent sleep. I'm not sure if this will persist throughout the Igor session, but you could also set up Igor to invoke this command during function execution to prevent sleep only when the function is running.

Here are some such functions, from the Igor help:

The function to execute the shell script...
Function/S ExecuteUnixShellCommand(uCommand, printCommandInHistory, printResultInHistory)
    String uCommand             // Unix command to execute
    Variable printCommandInHistory
    Variable printResultInHistory

    if (printCommandInHistory)
        printf "Unix command: %s\r", uCommand
    endif

    String cmd
    sprintf cmd, "do shell script \"%s\"", uCommand
    ExecuteScriptText cmd

    if (printResultInHistory)
        Print S_value
    endif

    return S_value
End


Running the command...
ExecuteUnixShellCommand("pmset noidle", 1, 1)


The Igor hook...
Function IgorStartOrNewHook(igorApplicationNameStr)
    String igorApplicationNameStr
    ExecuteUnixShellCommand("pmset noidle",1,1)
end


...I'm not guaranteeing this will work, but it or a similar approach should invoke an assertion to the system.
I've resisted installing Caffeine, but I may well give your suggestion a try. Thanks for the details! Nathan
"caffeinate" is a built-in command in 10.8 that essentially replaces "pmset noidle", with the exception that it can be applied to specific processes so it is only active when the process is running.
By the way, using the "pmset noidle" command in the hook above is not the best use, as Igor apparently waits for the command to complete before continuing, which in the hook will hang the program until you cancel procedure execution. However, canceling the execution doesnt close the "pmset" command in the system though, which will remain running and will maintain a file lock on Igor-related files (procedures, etc.). This will make them uneditable both in Igor and elsewhere until you kill the running "pmset" processes or restart the system.

The use of this command is still doable, but you would need to call it within each function and then issue the "killall pmset" command to clear the locks at the end of the function.

Anyway...its an explorable option.
Ah, thanks for the clarification on the "caffeinate" command; I thought you were referring to the freeware (or shareware?) utility "Caffeine" which I admittedly I haven't looked too much into. I'll have a look at the man pages but it's approaching the limits of my understanding of the back end of the OS . . .