# How are scripts from commandline executed

to state it right away, I'm a complete beginner to scripting in blender.

I have a simple python script to change the text of a text element. The script works when run from the scripting tab in blender but does nothing in commandline.

content of the script is

import bpy

bpy.data.objects["custom_text"].data.body = "hello 123"


and invoke it on the commandline with

blender -b test.blend -f 1 --python ./test.py


but the text in the rendered file comes out unchanged. I have no idea what the problem is, does the selection of the object not work, is the script executed at the right time (before rendering), does the setting of the data not work, ...

The script is currently executed after rendering. The order of CLI command matters for Blender. If you put the --python flag before -f it should work as expected.