Not sure if you’ve resolved your issue yet. I had the same issue with the scheduler - script would run from the terminal but not from the scheduler. I checked all the boxes for policy (permissions), then unchecked them one at a time to find out what I needed. It became clear that I needed ‘test’ to issue commands that didn’t really seem to fit the ‘test’ description. I also needed ‘policy’ for reasons that weren’t clear. Overall I find the documentation on this product to be abysmal, and not just the grammar/spelling. It’s laid out in a less than useful fashion and is very incomplete. Too bad I like the product so much - its price/performance can’t be beaten.
I am on a quest now to find a way to ‘trace’ my scripts as they run so I don’t have to keep adding ‘log info’ statements everywhere to figure out what’s going wrong. I’ve never seen such a powerful platform lack such a basic feature. Maybe I’ll find it today - have looked before though. At least today I saw someone else asking the same question. Hopefully he got a good answer.
You could try putting your script into a text file and running it from the command line with the import utility - that will give you a line number with syntax error. If there are none, then you can create debugging commands such as log output, or setting comments on certain objects, etc.