POV-Ray : Newsgroups : povray.programming : Executing povray using PHP : Re: Executing povray using PHP Server Time
28 Jun 2024 01:43:44 EDT (-0400)
  Re: Executing povray using PHP  
From: bbossard
Date: 20 Oct 2004 12:40:00
Message: <web.41769427ce5ae908e75460680@news.povray.org>
Thank you pan and Warp for your replies.  I figured out the problem after
almost completing this post, so I guess I will just finish it and maybe
someone else will find it helpful.

First off, I am using the very latest version of povray I could get,
v.3.6.1, built from source.  I have not been a povray user for very long,
but would like my website to embody the open source spirit, so povray
looked like the best option.

Secondly, I would prefer not to have to change my operating system to BSD,
although I appreciate you mentioning that it does work on that system, and
if I cannot resolve this problem any other way, I might have to consider
it.

Thirdly, I started tinkering around with a few of the tips provided by pan,
and came up with some new findings.  The display option must be depricated
or the syntax has changed, it was not recognized by 3.6.1.  I also added
switch to run it in backgroud, and then added a echo statement before the
exec statement.

I have attached my updated code to this post... It runs from the
command-line fine (i.e.  php test.php).  If I try to execute it from a web
browser though, the page will display

sh: line 1: povray: command not found

ahhhh.... Just figured out the problem, the user apache doesn't have the
/usr/local/bin directory in it's path or something, so you must change the
exec line to

echo exec ('/usr/local/bin/povray test.pov +H600 +W800 -display 0:3 -D +A
+FN8 -Otest.png -GAtest.out /dev/null 2>&1 &');

Sweet, works now, thanks to everyone that posted.  Like I said, maybe this
will help someone in the future.

Brad


<?
// test.php

$pov_file_pointer = fopen("test.pov", "w");
if (!$pov_file_pointer) die ('Unable to create POV file.');


fwrite($pov_file_pointer,"#include "colors.inc"n");
fwrite($pov_file_pointer,"background { color Black }n");
fwrite($pov_file_pointer,"global_settings { assumed_gamma 2.2 }nn");

fwrite($pov_file_pointer,"camera {n");
fwrite($pov_file_pointer,"tlocation < 0.0, 0.0, 30.0 >n");
fwrite($pov_file_pointer,"tlook_at < 0.0, 0.0, 0.0 >n");
fwrite($pov_file_pointer,"}n");

fwrite ($pov_file_pointer,"cylindern");
fwrite ($pov_file_pointer,"{n");
fwrite ($pov_file_pointer,"t<30.0 ,30.0, 0.0>n");
fwrite ($pov_file_pointer,"t<-30.0, 30.0, 0.0>n");
fwrite ($pov_file_pointer,"t100.0 n");
fwrite ($pov_file_pointer,"topen n");
fwrite ($pov_file_pointer,"tfinish { n");
fwrite ($pov_file_pointer,"ttambient 1.0n");
fwrite ($pov_file_pointer,"ttdiffuse 0.8n");
fwrite ($pov_file_pointer,"ttphong 1n");
fwrite ($pov_file_pointer,"t}n");
fwrite ($pov_file_pointer,"tpigment { color red 0 green 0 blue 1 }n");
fwrite ($pov_file_pointer,"}n");

fclose($pov_file_pointer);

echo exec ('povray test.pov +H600 +W800 -display 0:3 -D +A +FN8 -Otest.png
-GAtest.out /dev/null 2>&1 &');

?>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.