1
$\begingroup$

I am running blender in background and supplying a python script. Now I want to access the console output of the python script, and do some http calls based on that. However, I 'm unable to figure out how to get the console output as blender is running in the background and the process has exited.

Can someone tell me how to achieve that?

$\endgroup$
1
$\begingroup$

The exact way you handle this will depend on several factors like what OS your running and how much output you expect to retrieve. More detailed help is better suited to stackoverflow as it isn't specifically blender related.

Using python as a more cross platform solution, you should read through the subprocess page which explains and offers several options. Basically output from prints in your script can be retrieved from stdout while errors are normally sent through stderr. For simple needs you can just get the contents of stdout when blender has finished into a string to scan through, while for more advanced needs you can setup pipes and process the output line by line as it comes out.

For *nix like systems such as OSX and Linux you could capture blenders output in a shell script with a line like output=$(blender -b -P myscript.py) - with windows you should be able to do something similar with a .bat script and with OSX you could also use an applescript.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.