Onload from commandline problem

I have written a simple script and linked it to the scene to run onload.

On opening the file in blender it does as expected (Moves the sphere and renders the result saving the file)

On running the file from commandline I have noticed that it does render the image and asves it correctly but it does not run the python sript

The script is simply :


import Blender  
from Blender import *
from Blender.Scene import Render
import sys 
obj=Blender.Object.Get("Sphere.001") 
obj.setLocation((5.0, 1.0, 1.0))
Blender.Redraw()
scn = Scene.GetCurrent()
Render.EnableEdgeAll(1)
context = scn.getRenderingContext()
context.enableExtensions(1)
context.startFrame(1)
context.render()


And the command line is

blender -b my.blend 

I have dropped the -f 1 from the command line as it is rendering out via the python command anyway.

Any thoughts as to why this not running from a command line but is running from a blender gui?

Thanks
Chimpoid