Why not put your code in a mac routine and call the routine from your script file. Might be easier.