[GRASS-user] --exec interface not working with a script

Hello list,

This is maybe a very silly question, but I do not know what I am missing. I’m trying to run a script using the --exec interface but using the following command, I get:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec test.sh
Cleaning up temporary files…
Starting GRASS GIS…
Executing <test.sh> …
ERROR: Execution of <test.sh> failed:
[Errno 2] No such file or directory
Exiting…

test.sh looks like this:

#!/bin/bash
g.region -p
g.list type=raster
r.info elevation

When I just run the commands with the --exec flag, they work fine. For example:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec g.region -p
Cleaning up temporary files…
Starting GRASS GIS…
Executing <g.region -p> …
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: a=6378137 es=0.006694380022900787
north: 320000
south: 10000
west: 120000
east: 935000
nsres: 500
ewres: 500
rows: 620
cols: 1630
cells: 1010600
Execution of <g.region -p> finished.
Cleaning up temporary files…

What am I missing? Do I need to add extra permissions to my grassdata folder? I find it strange since I’ve used the exec interface with scripts before without any issues.

Thanks much in advance!

Cheers,

Vero

ps: in case it matters, I use fedora24, grass trunk r69962M.

Hi Vero !

Le 5 décembre 2016 21:35:04 GMT+01:00, Veronica Andreo <veroandreo@gmail.com> a écrit :

Hello list,

This is maybe a very silly question, but I do not know what I am
missing.
I'm trying to run a script using the --exec interface but using the
following command, I get:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec
test.sh
Cleaning up temporary files...
Starting GRASS GIS...
Executing <test.sh> ...
ERROR: Execution of <test.sh> failed:
[Errno 2] No such file or directory
Exiting...

Try giving it the full path to test.sh.

Moritz

test.sh looks like this:

#!/bin/bash
g.region -p
g.list type=raster
r.info elevation

When I just run the commands with the --exec flag, they work fine. For
example:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec
g.region -p
Cleaning up temporary files...
Starting GRASS GIS...
Executing <g.region -p> ...
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: a=6378137 es=0.006694380022900787
north: 320000
south: 10000
west: 120000
east: 935000
nsres: 500
ewres: 500
rows: 620
cols: 1630
cells: 1010600
Execution of <g.region -p> finished.
Cleaning up temporary files...

What am I missing? Do I need to add extra permissions to my grassdata
folder? I find it strange since I've used the exec interface with
scripts
before without any issues.

Thanks much in advance!

Cheers,
Vero

ps: in case it matters, I use fedora24, grass trunk r69962M.

------------------------------------------------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On Mon, Dec 5, 2016 at 9:35 PM, Veronica Andreo <veroandreo@gmail.com> wrote:

Hello list,

This is maybe a very silly question, but I do not know what I am missing.
I'm trying to run a script using the --exec interface but using the
following command, I get:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec test.sh

Like this the "test.sh" must be in the current path.
So:
- either give the full path (as Moritz wrote)
- or call it like this: .... --exec sh test.sh

Cheers
Markus

On 05/12/16 23:06, Markus Neteler wrote:

On Mon, Dec 5, 2016 at 9:35 PM, Veronica Andreo <veroandreo@gmail.com> wrote:

Hello list,

This is maybe a very silly question, but I do not know what I am missing.
I'm trying to run a script using the --exec interface but using the
following command, I get:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec test.sh

Like this the "test.sh" must be in the current path.
So:
- either give the full path (as Moritz wrote)
- or call it like this: .... --exec sh test.sh

And just to make sure: If you use the full path (or ./test.sh), test.sh has to have the executable bit set, i.e. chmod +x test.sh.

Moritz

Hola!

See? I knew it was a silly question :stuck_out_tongue: Thank you for your answers!

It works both with sh test.sh and ./test.sh (@Moritz, yes the +x was there)

Thanks again! Will send a diff with the example for the manual page.

Cheers,
Vero

···

2016-12-06 8:33 GMT+01:00 Moritz Lennert <mlennert@club.worldonline.be>:

On 05/12/16 23:06, Markus Neteler wrote:

On Mon, Dec 5, 2016 at 9:35 PM, Veronica Andreo <veroandreo@gmail.com> wrote:

Hello list,

This is maybe a very silly question, but I do not know what I am missing.
I’m trying to run a script using the --exec interface but using the
following command, I get:

grass73svn /home/veroandreo/grassdata/nc_spm_08_grass7/user1/ --exec test.sh

Like this the “test.sh” must be in the current path.
So:

  • either give the full path (as Moritz wrote)
  • or call it like this: … --exec sh test.sh

And just to make sure: If you use the full path (or ./test.sh), test.sh has to have the executable bit set, i.e. chmod +x test.sh.

Moritz

On Tue, Dec 6, 2016 at 9:55 AM, Veronica Andreo <veroandreo@gmail.com> wrote:
...

It works both with sh test.sh and ./test.sh (@Moritz, yes the +x was there)

Thanks again! Will send a diff with the example for the manual page.

I have used that diff (thanks) and expanded it for Python. Submitted in r70014.

The Python example therein still needs an improvement to find GISBASE.
Then it should be backported.

Markus

On Tue, Dec 6, 2016 at 12:27 PM, Markus Neteler <neteler@osgeo.org> wrote:

On Tue, Dec 6, 2016 at 9:55 AM, Veronica Andreo <veroandreo@gmail.com>
wrote:
...
> It works both with sh test.sh and ./test.sh (@Moritz, yes the +x was
there)
>
> Thanks again! Will send a diff with the example for the manual page.

I have used that diff (thanks) and expanded it for Python. Submitted in
r70014.

The Python example therein still needs an improvement to find GISBASE.

I can also see the comment there

TODO: how to find GISBASE? must be defined

but I still don't understand. What is the issue with that? GRASS Python
modules don't need to check or directly use GISBASE and this is the same
case.

Does the code in the example run? (It runs for me.)

Vaclav

Then it should be backported.

On Dec 6, 2016 7:47 PM, “Vaclav Petras” <wenzeslaus@gmail.com> wrote:

On Tue, Dec 6, 2016 at 12:27 PM, Markus Neteler <neteler@osgeo.org> wrote:

TODO: how to find GISBASE? must be defined

but I still don’t understand. What is the issue with that? GRASS Python modules don’t need to check or directly use GISBASE and this is the same case.

Ok good.

Does the code in the example run? (It runs for me.)

For me only when running in the source code directory (but I never use “make install”).

If the example is reasonable then I’ll complete the backport and remove the comment.

Markus

On Tue, Dec 6, 2016 at 2:10 PM, Markus Neteler <neteler@osgeo.org> wrote:

> Does the code in the example run? (It runs for me.)

For me only when running in the source code directory (but I never use
"make install").

I can run it from the compiled source after `make` being in my home dir.

If the example is reasonable then I'll complete the backport and remove
the comment.

It is reasonable.