Your question is still too generic to give you any specific example. But you may read another FAQ. It summaries everything about scripting and links to examples.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.