You can do something like this. Run an inline python script that will call a string and run it as it's own shell command.
# test_run.py
# The test file to run.
import sys
arg1 = sys.argv[1]
arg2 = sys.argv[2]
if __name__ == "__main__":
string = f"""
Argument 1: {arg1}
Argument 2: {arg2}
"""
print(string)
Then the command that you would in the terminal. If you wanted to run that script alone, with it's two arguments.
python3 ~/scripts/random/test_run.py first_arg second_arg
So then use the subprocess module, which allows you to call shell commands from within python. Throw that into the blender command line with the argument --python-text
and you should get.
blender -b --python-expr "import subprocess; subprocess.run('python3 ~/scripts/random/test_run.py first_arg second_arg', shell=True)"
You might have to change the part that says python3
to the python that runs natively with blender. I'm running a custom install of blender and I haven't configured the command line to run as normal, it's just a symlink to the .exe so I'm not sure about the exact specifics of running it in the Blender specific python environment.
But I think the mechanics of how to do it are all there.