This is a shell script wrapped around a line of AppleScript that I can to put an OS X machine to sleep. I used at(1) to generate all the housekeeping stuff (paths and variables): the actual command is the very last line.
#!/bin/sh
MANPATH=:/opt/local/share/man; export MANPATH
TERM_PROGRAM=Apple_Terminal; export TERM_PROGRAM
GPG_AGENT_INFO=/Users/paul/.gnupg/S.gpg-agent:776:1; export GPG_AGENT_INFO
TERM=xterm-color; export TERM
SHELL=/bin/bash; export SHELL
CLICOLOR=1; export CLICOLOR
TMPDIR=/var/folders/js/82lhv5lh8xn_1r006s6qx0g80000gn/T/; export TMPDIR
Apple_PubSub_Socket_Render=/tmp/launch-vpi61E/Render; export Apple_PubSub_Socket_Render
HTML_TIDY=/Users/paul/.tidyrc; export HTML_TIDY
TERM_PROGRAM_VERSION=303; export TERM_PROGRAM_VERSION
TERM_SESSION_ID=A236A172-44B1-4955-8B2D-3EEB9C1E2D52; export TERM_SESSION_ID
USER=paul; export USER
COMMAND_MODE=unix2003; export COMMAND_MODE
SSH_AUTH_SOCK=/tmp/launch-kZWH3Y/Listeners; export SSH_AUTH_SOCK
__CF_USER_TEXT_ENCODING=0x1F5:0:0; export __CF_USER_TEXT_ENCODING
Apple_Ubiquity_Message=/tmp/launch-q0RW5z/Apple_Ubiquity_Message; export Apple_Ubiquity_Message
LSCOLORS=ExFxCxDxBxegedabagacad; export LSCOLORS
PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/bin:/usr/local/mysql/bin; export PATH
PWD=/Users/paul; export PWD
EDITOR=/usr/bin/vim; export EDITOR
LANG=en_US.UTF-8; export LANG
SHLVL=1; export SHLVL
HOME=/Users/paul; export HOME
LOGNAME=paul; export LOGNAME
DBUS_SESSION_BUS_ADDRESS=launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET; export DBUS_SESSION_BUS_ADDRESS
LC_CTYPE=en_US.UTF-8; export LC_CTYPE
INFOPATH=:/opt/local/share/info; export INFOPATH
DISPLAY=/tmp/launch-LrbuQi/org.x:0; export DISPLAY
SECURITYSESSIONID=186a5; export SECURITYSESSIONID
_=/usr/bin/at; export _
osascript -e 'tell app "Finder" to sleep'