The x server must run when you issue the commands. If the command do not require root access, you could run them as a user startup program (Startup Applications in Unity Dash).
Here (
http://askubuntu.com/questions/63791...rtup-in-ubuntu) I see a probably better suggestion, which involves placing the script under /etc/X11/Xsession.d/