When running a Perl-script from the grass-shell, grass commands can be started via backticks or using "system()". However, this is not suitable to set variables such as GRASS_HEIGHT/WIDTH etc (Scoping).
Has anybody tackled this issue before ?
--
Dr. Peter Löwe
Diplom-Geograph
<loewe@geomancers.net>
<peter.loewe@gmx.de>
"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
Hi Peter,
%ENV gives you the environment variables,
if ($ENV{GISBASE}){
&main();
}
else {
print "You have to run GRASS first!"
}
you can also read from stdin:
@region = `g.region -g`
jachym
On Thu, Aug 03, 2006 at 09:44:53AM +0200, peter.loewe@gmx.de wrote:
When running a Perl-script from the grass-shell, grass commands can be started via backticks or using "system()". However, this is not suitable to set variables such as GRASS_HEIGHT/WIDTH etc (Scoping).
Has anybody tackled this issue before ?
--
Dr. Peter Löwe
Diplom-Geograph
<loewe@geomancers.net>
<peter.loewe@gmx.de>
"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
GDF-Hannover
Mengendamm 16d
30177 Hannover
Germany
e-mail: cepicky@gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507
%ENV gives you the environment variables,
if ($ENV{GISBASE}){
&main();
}
else {
print "You have to run GRASS first!"
}
you can also read from stdin:
@region = `g.region -g`
Hello Jachym,
that's true. However, neither `export GRASS_WIDTH=42` nor system "export GRASS_WIDTH=42" can be used to set the variables for later commands to make use of the settings (aka generate a huge PNG). Within the GRASS environment, the GRASS_HEIGHT/WIDTH will still default to 640/480.
A remarkably awkward workaround would be to create a shell-script from within the perl environment and run it later. but i believe theremust be a better way.
Peter
--
Dr. Peter Löwe
Diplom-Geograph
<loewe@geomancers.net>
<peter.loewe@gmx.de>
Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
#!/usr/bin/perl -w
$ENV{GRASS_WIDTH} = 20;
$ENV{GRASS_HEIGHT} = 20;
system("d.mon start=PNG");
system("d.rast soils");
system("d.mon stop=PNG");
jachym
On Thu, Aug 03, 2006 at 10:01:11AM +0200, "Peter Löwe" wrote:
>%ENV gives you the environment variables,
>if ($ENV{GISBASE}){
> &main();
>}
>else {
> print "You have to run GRASS first!"
>}
>
>you can also read from stdin:
>
>@region = `g.region -g`
Hello Jachym,
that's true. However, neither `export GRASS_WIDTH=42` nor system "export GRASS_WIDTH=42" can be used to set the variables for later commands to make use of the settings (aka generate a huge PNG). Within the GRASS environment, the GRASS_HEIGHT/WIDTH will still default to 640/480.
A remarkably awkward workaround would be to create a shell-script from within the perl environment and run it later. but i believe theremust be a better way.
Peter
--
Dr. Peter Löwe
Diplom-Geograph
<loewe@geomancers.net>
<peter.loewe@gmx.de>
Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
GDF-Hannover
Mengendamm 16d
30177 Hannover
Germany
e-mail: cepicky@gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507