POV-Ray : Newsgroups : povray.unix : Need Help With Running POV-Ray Through PHP : Re: Need Help With Running POV-Ray Through PHP Server Time
18 May 2024 09:49:34 EDT (-0400)
  Re: Need Help With Running POV-Ray Through PHP  
From: Jess
Date: 12 Mar 2011 14:20:00
Message: <web.4d7bc718594502e27a0819aa0@news.povray.org>
> 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;
> }
>
> ----------------
I copied the above code into another file. Here's my output from the shell:
[jlb41@wyrd public_html]$ ./a.out
Hello, world
arg 0 : "./a.out"
This is pid 10972
Run as user 1547 (effective 1547)
The current directory is : /home/jlb41/public_html
Opendir /tmp returned: 0xb45030
Filename pulse-fIaYVQ4ftTFx
Filename pulse-ddsuEvxoRlP9
Filename .X0-lock
Filename orbit-gdm
Filename .ICE-unix
Filename .X11-unix
Filename 4d24887f11a5c
Filename lost+found
Filename orbit-acrum
Filename virtual-acrum.0BJ3Jx
Filename .esd-501
Filename ..
Filename pulse-OmdOnASl52ii
Filename .
Filename .htaccess
Filename pear
Filename virtual-acrum.ZeaNM4
Closedir returned 0

And the output from PHP:
Hello, world
arg 0 : "./a.out"
This is pid 10971
Run as user 48 (effective 48)
The current directory is : /home/jlb41/public_html
Opendir /tmp returned: 0x1601030
Filename pulse-fIaYVQ4ftTFx
Filename pulse-ddsuEvxoRlP9
Filename .X0-lock
Filename orbit-gdm
Filename .ICE-unix
Filename .X11-unix
Filename 4d24887f11a5c
Filename lost+found
Filename orbit-acrum
Filename virtual-acrum.0BJ3Jx
Filename .esd-501
Filename ..
Filename pulse-OmdOnASl52ii
Filename .
Filename .htaccess
Filename pear
Filename virtual-acrum.ZeaNM4
Closedir returned 0

When I run the code from both the shell and PHP, the /tmp value changes and the
pid increments. Is that supposed to happen?

I forgot to mention too that I can run shell commands like ls and dir from PHP.
Just not POV-Ray. I think it might have to do with some sort of permission
denial by PHP that I'm not knowing about.


Post a reply to this message

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