|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'm working on a project that involves writing input from a text box to a POV
file, running POV-Ray (version 3.6.1) through a UNIX shell via a website and
outputting the resulting PNG file. Here is the code I have so far:
<?php
//Code for writing to a file
$input = $_POST['input'];
$file = "object.pov";
$save = fopen($file, 'w');
fwrite($save, $input);
fclose($save);
//Code for executing a shell command
system("povray object.pov");
?>
<form method="post" action="write_test.php">
<textarea name="input" rows="10" cols="61">
</textarea>
<input type="submit" name="button" value="Write" />
</form>
<img src="object.png"/>
I've tried using shell_exec(), exec(), and system() to render a test file, but
it doesn't seem to work from the test PHP webpage I'm using. Oddly enough, it
works when I run the PHP script through the shell.
Also, when I tried running it through system() with a return value variable, I
got a return value of 1, which I think means there's an error.
I'm not sure if this detail is important, but in order to write to the POV file,
I had to change the file permission code to 666. I wouldn't think the file
permissions would be causing this problem, but maybe it actually is and I'm just
not realizing it.
So, is there something else I should be doing to get this to work? Is it even
possible to run POV-Ray through PHP?
Post a reply to this message
|
|
| |
| |
|
|
From: Jaime Vives Piqueres
Subject: Re: Need Help With Running POV-Ray Through PHP
Date: 10 Mar 2011 13:43:08
Message: <4d791bbc@news.povray.org>
|
|
|
| |
| |
|
|
> I've tried using shell_exec(), exec(), and system() to render a test
> file, but it doesn't seem to work from the test PHP webpage I'm
> using. Oddly enough, it works when I run the PHP script through the
> shell.
I've used it with shell_exec(), but IIRC, I had to call povray with
the full path (/usr/local/bin/povray in my case).
Regards,
--
Jaime Vives Piqueres
La Persistencia de la Ignorancia
http://www.ignorancia.org
Post a reply to this message
|
|
| |
| |
|
|
From: Le Forgeron
Subject: Re: Need Help With Running POV-Ray Through PHP
Date: 10 Mar 2011 13:54:47
Message: <4d791e77@news.povray.org>
|
|
|
| |
| |
|
|
Le 10/03/2011 17:06, Jess nous fit lire :
> I'm working on a project that involves writing input from a text box to a POV
> file, running POV-Ray (version 3.6.1) through a UNIX shell via a website and
> outputting the resulting PNG file. Here is the code I have so far:
> I've tried using shell_exec(), exec(), and system() to render a test file, but
> it doesn't seem to work from the test PHP webpage I'm using. Oddly enough, it
> works when I run the PHP script through the shell.
>
> Also, when I tried running it through system() with a return value variable, I
> got a return value of 1, which I think means there's an error.
>
> I'm not sure if this detail is important, but in order to write to the POV file,
> I had to change the file permission code to 666. I wouldn't think the file
> permissions would be causing this problem, but maybe it actually is and I'm just
> not realizing it.
>
> So, is there something else I should be doing to get this to work? Is it even
> possible to run POV-Ray through PHP?
Do you own the webserver ?
Does the webserver run in a chroot ?
Are you aware that php get a property "max_execution_time" which would
limit the time available...
can you provide the phpinfo() ? (or check it yourself)
For instance, with safe_mode on, only binary in safe_mode_exec_dir would
get allowed.
Is povray inside the php-path ? (or would you provide the full path
instead ? (hint: if chroot, beware to use the right value!)
Have you turn off the display of povray (trying to open a X11 display is
a bad idea when launched from script)
What about instead of dynamic rendition, have a render farm:
* The web page create the file.pov in a directory (automatic naming).
* a demon scan the directory and run povray for the new file (moving
the file from "./to_render" to "./in_progress".
* when the image is finished in "./in_progress", both the pov & image
are moved to "./done"
* the submission page returned a page with refresh and the img src=link
to "./done/" image... when ready, it appears.
You might also want some automatic clean up...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jaime Vives Piqueres <jai### [at] ignoranciaorg> wrote:
> > I've tried using shell_exec(), exec(), and system() to render a test
> > file, but it doesn't seem to work from the test PHP webpage I'm
> > using. Oddly enough, it works when I run the PHP script through the
> > shell.
>
> I've used it with shell_exec(), but IIRC, I had to call povray with
> the full path (/usr/local/bin/povray in my case).
>
> Regards,
>
> --
> Jaime Vives Piqueres
>
> La Persistencia de la Ignorancia
> http://www.ignorancia.org
I tried using shell_exec('usr/bin/povray object.pov'), but it still doesn't
work.
Thanks for the suggestion, though.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Do you own the webserver ?
>
> Does the webserver run in a chroot ?
>
> Are you aware that php get a property "max_execution_time" which would
> limit the time available...
>
> can you provide the phpinfo() ? (or check it yourself)
>
> For instance, with safe_mode on, only binary in safe_mode_exec_dir would
> get allowed.
>
> Is povray inside the php-path ? (or would you provide the full path
> instead ? (hint: if chroot, beware to use the right value!)
>
> Have you turn off the display of povray (trying to open a X11 display is
> a bad idea when launched from script)
>
> What about instead of dynamic rendition, have a render farm:
> * The web page create the file.pov in a directory (automatic naming).
> * a demon scan the directory and run povray for the new file (moving
> the file from "./to_render" to "./in_progress".
> * when the image is finished in "./in_progress", both the pov & image
> are moved to "./done"
> * the submission page returned a page with refresh and the img src=link
> to "./done/" image... when ready, it appears.
>
> You might also want some automatic clean up...
I don't know if the web server is running on chroot, but I did find that the
server's PHP installation has a max_execution_time of 30 and safe mode is off.
POV-Ray isn't in the PHP path, but running it from the file path
(/usr/bin/povray) didn't help.
Post a reply to this message
|
|
| |
| |
|
|
From: Jaime Vives Piqueres
Subject: Re: Need Help With Running POV-Ray Through PHP
Date: 11 Mar 2011 05:56:10
Message: <4d79ffca$1@news.povray.org>
|
|
|
| |
| |
|
|
>
> I don't know if the web server is running on chroot, but I did find
> that the server's PHP installation has a max_execution_time of 30 and
> safe mode is off.
>
> POV-Ray isn't in the PHP path, but running it from the file path
> (/usr/bin/povray) didn't help.
>
Did you try Jerome advice to turn off the display? ...I assumed you
were turning it off already, but now I don't see the -d switch on your
system call.
Additionally, you can write the streams to a file to try to spot the
problem (see output options on the docs).
--
Jaime Vives Piqueres
La Persistencia de la Ignorancia
http://www.ignorancia.org
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Did you try Jerome advice to turn off the display? ...I assumed you
> were turning it off already, but now I don't see the -d switch on your
> system call.
>
> Additionally, you can write the streams to a file to try to spot the
> problem (see output options on the docs).
>
>
> --
> Jaime Vives Piqueres
>
> La Persistencia de la Ignorancia
> http://www.ignorancia.org
I didn't try turning off the display until today, but that also didn't work.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 11/03/2011 21:57, Jess nous fit lire :
> I didn't try turning off the display until today, but that also didn't work.
>
>
How does "povray --benchmark" perform from your webserver/php ?
(and directly from command line ?)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le_Forgeron <jgr### [at] freefr> wrote:
> Le 11/03/2011 21:57, Jess nous fit lire :
> > I didn't try turning off the display until today, but that also didn't work.
> >
> >
> How does "povray --benchmark" perform from your webserver/php ?
> (and directly from command line ?)
The benchmark render took 22 minutes to complete from the command line, but
didn't work at all from PHP (running it with system still gives me a return
value of 1, which I found out is a generic error code).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Le 12/03/2011 07:57, Jess nous fit lire :
> Le_Forgeron <jgr### [at] freefr> wrote:
>> Le 11/03/2011 21:57, Jess nous fit lire :
>>> I didn't try turning off the display until today, but that also didn't work.
>>>
>>>
>> How does "povray --benchmark" perform from your webserver/php ?
>> (and directly from command line ?)
>
> The benchmark render took 22 minutes to complete from the command line, but
> didn't work at all from PHP (running it with system still gives me a return
> value of 1, which I found out is a generic error code).
>
>
Ok, time to switch povray for a hello_world program then.
(i.e. write & compile a hello_world program, and get it called from
shell then php/webserver.
1. Does it work the same ? (does it fail the same way ?)
2. second level debugging: add more printf in the the hello program to
display:
* all the arguments/parameter (including argv[0]),
* process id ( getpid() )
* user id (both real & effective : getuid(), geteuid() )
* current directory ( getcwd() or get_current_dir_name() )
* perform some i/o operation on the disk (like opendir("/tmp"), and
display all entries ? compare with actual content of /tmp)
Something like that:
-----------------------
#include <sys/types.h>
#include <dirent.h>
int main(int argc,char**argv)
{
int ii;
DIR* tmpdir;
struct dirent *entry;
printf("Hello, world\n");
for(ii=0;ii<argc;ii++)
{
printf("arg %d : \"%s\"\n",ii,argv[ii]);
}
printf("This is pid %d\n",getpid());
printf("Run as user %d (effective %d)\n",getuid(),geteuid());
printf("The current directory is : %s\n",get_current_dir_name());
tmpdir=opendir("/tmp");
printf("Opendir /tmp returned: %p\n",tmpdir);
if (tmpdir)
{
do
{
entry = readdir(tmpdir);
if (entry)
{
printf("Filename %s\n",entry->d_name);
}
} while (entry);
ii=closedir(tmpdir);
printf("Closedir returned %d\n",ii);
}
return 0;
}
----------------
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|