[GRASSLIST:4184] Re: redirecting v.what results to file using batch-grass

Glynn Clements glynn.clements at virgin.net
Wed Jul 31 06:46:40 EDT 2002


Roger Bivand wrote:

> > > I've managed to get the v.what command to redirect it's results to file
> > > (using >) but I'm having some problems doing this when using
> > > batch-grass.sh.  I always get the same error message:
> > > 
> > > Sorry <>> is not a valid option
> > > Sorry <v.whatoutput> is not a valid option
> > > 
> > > and I get the same if using | instead of > (1st error message obviously
> > > changes the invalid sign)
> > > 
> > > My full batch-grass line is (in Pascal)
> > > 
> > > Exec('batch-grass.sh stellenbosch andrew v.what map=stbstreets_wgs84
> > > east_north=18.830,-33.935 > v.whatoutput','');
> > 
> > and:
> > 
> > > Sorry, I forgot to specify that the result is redirected to file if
> > > batch-grass.sh is run on the command line, but I get the errors when
> > > batch-grass is run from another programme (Pascal).
> > > By the way, batch-grass works fine using Exec in Pascal, the errors are
> > > generated when I try redirect the result to file using batch-grass.
> > 
> > This appears to be an issue with the way that the Exec() function
> > works.
> > 
> > The redirection operators are implemented by the shell. Presumably
> > Exec() doesn't use the shell, in which case you won't be able to use
> > any shell constructs in the command.
> > 
> 
> Maybe then put a /bin/sh in front of the batch-grass.sh,

Actually, you would need to use the "-c" switch, i.e.

	/bin/sh -c <command>

But you would need to figure out how to ensure that the command is
passed as a single argument. E.g. if double quotes do the trick, then
the following would work:

Exec('/bin/sh -c "batch-grass.sh stellenbosch andrew v.what map=stbstreets_wgs84 east_north=18.830,-33.935 > v.whatoutput"','');

> and or make a 
> local copy of batch-grass.sh inside a wrapper doing the redirection?

For this particular instance, that would probably be simpler. However,
if you are planning on doing a lot of this sort of thing, then it may
be worth the effort of determining exactly how Exec() works, and how
to make it do what you want.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-user mailing list