Using PHP exec() to kick off a blender render

Don’t know if anyone has managed to acheive this ( although BRender looks like it does this ).

I’m just trying to use PHP start blender in command-line mode and render an object on for display on my webserver.

I’ve got the command-line correct ( as in it renders the file exactly as I want when run from a command prompt ) but any variant of PHPs exec() function just fails. The weird thing is that it definitely seems to be executing blender, because if I pass in malformed arguments I get a correct response -eg something like ‘Blender could not open the file blah blah’ then ‘Blender quit’

This is all on Win7, running apache 2.2 and php5.2 BTW. Apologies that its not blender-specific, but its quite closely related i think!

EDIT:
I’ve also added a stackoverflow question here with a bit more detail, if anyone here uses SO and can answer the points could be yours!

http://stackoverflow.com/questions/10422711/how-to-render-a-file-with-blender-called-from-a-php-script

any help would be greatly appreciated :slight_smile:

I am having a very similar problem:

Blender (2.80) is installed on AWS in directory /home/ec2-user.

php is run on the same server from /var/www/html/wed

I have access through cli:

wed]$ ls /home/ec2-user

Lists contents of /home/ec2-user.

And access through php:

<?php<br />
$output = shell_exec('ls /home/ec2-user'); 
echo "<pre>$output</pre>"; 
?>

Lists contents of /home/ec2-user.

I can run Blender through cli:

wed]$ /home/ec2-user/blender280/blender -b -noaudio proj007/font-sample.blend --python proj007/font-samples.py

Runs the blender script (proj007/font-samples.py) and outputs 663 png files to /var/www/html/wed/fonts.

But not through php:

<?php
$output = shell_exec('/home/ec2-user/blender280/blender -b -noaudio proj007/font-sample.blend --python proj007/font-samples.py'); 
echo "<pre>$output</pre>"; 
?>

Nothing.

Commands are copied and pasted so there is no typo.

If you can answer MeiaLua’s on SO, double your points by answering mine:

Instead of:
$output = shell_exec(’/home/ec2-user/blender280/blender -b -noaudio proj007/font-sample.blend --python proj007/font-samples.py’);

I used:
$output = shell_exec(‘cd /home/ubuntu/ && blender280/blender -b -noaudio proj007/font-sample.blend --python proj007/font-samples.py’);

This works.