[GRASS5] Grass with PHP (newbie question)
Namnath, Sharyn
NamnatSR at NV.DOE.GOV
Tue Aug 17 14:16:24 EDT 2004
Glynn,
Thanks for your help. The one thing that helped the most was the stderr
redirect :) I was able to see what was going wrong and fix it. It turns
out, the mapset directory/subdirectories were not owned by the username
under which the webserver runs. I changed that and viola! It works like a
champ! Thanks ever so much.
- sharyn
> -----Original Message-----
> From: Glynn Clements [mailto:glynn.clements at virgin.net]
> Sent: Tuesday, August 17, 2004 6:48 AM
> To: Namnath, Sharyn
> Cc: Grass5 list (grass5 at grass.itc.it)
> Subject: RE: [GRASS5] Grass with PHP (newbie question)
>
>
> Namnath, Sharyn wrote:
>
> > Thanks for your reply. Yes, I do mean running GRASS programs from a PHP
> > script via "system" calls. I've been playing with setting the
> environment
> > variables, but it still doesn't work. I tried doing a simple version
> call
> > and piping it into a file. The file gets created, but there is nothing
> > inside of it. It just creates a zero-length file.
> >
> > Here is the code I'm using :
> >
> > <?php
> > putenv("GISBASE=/Applications/Grass/grass53");
> > putenv("GISRC=/Users/administrator/.grassrc5");
> > putenv("GRASS_LOCATION=$location");
> > putenv("GRASS_PNGFILE=/Users/administrator/Sharyn.png");
> > putenv("DYLD_LIBRARY_PATH=/Applications/Grass/grass53/lib");
> > putenv("GRASS_TRUCOLOR=TRUE");
> > putenv("GRASS_PNG_COMPRESSION=0");
> >
> > system("env > /Users/administrator/Sites/click/environment_vars.txt");
> >
> > system("/Applications/Grass/grass53/bin/g.version >
> /Users/administrator/Sites/click/version_info.txt");
> > ?>
>
> Have you checked the server/PHP logs for error messages?
>
> The attempt to run g.version may result in error messages being
> written to stderr. I don't know how mod_php handles this, but anything
> written to stderr by CGI scripts usually end's up in Apache's
> error_log file.
>
> Alternatively, you could redirect stderr directly, e.g.:
>
> system(".../g.version > .../version_info.txt 2> .../version_errors.txt");
>
> > The environment variables are echoed to the environment_vars.txt file
> just
> > fine :
>
> >
> PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServic
> es
>
> Yuo also need to add $GISBASE/bin and $GISBASE/scripts to PATH; some
> GRASS programs run other GRASS programs/scripts; this will fail if
> those directories aren't in $PATH.
>
> --
> Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list