Sleep from a script/program

Martin Hofmann wrote on :

I am trying to do something that should be simple but I can't quite see how. What I would like to do is simply to put the computer to sleep from a shell script (or from a program). The reason is simple, I want to run this script in case of a power failure, to save battery life. I realize that awakening the computer is another issue but I am thinking on using the wakeonlan feature for that.

Thanks, Martin Hofmann