[GRASS-user] windows format for temporary file path
Glynn Clements
glynn at gclements.plus.com
Fri Mar 16 01:14:34 EDT 2012
Richard Edmonds wrote:
> > It's possible that it's being used where it isn't appropriate
> > (i.e. where an absolute path is appropriate), but it's also possible
> > that you're passing an absolute path where a simple filename (or even
> > a map name) is actually required.
>
> Ah that makes sense,
> I was trying to use it to generate, then remove a temporary layer for
> use in the v.to.rast command. Apologies for not posting the command
> which generated the error.
>
> I have changed my bash script with the following which now generates
> only a name rather than a path and at least now the v.to.rast command runs.
>
> temp1="$$1"
The "usual" convention for temporary map names is to combine the name
of the script, "tmp", and the current PID, e.g.:
temprast="myscript.tmp.$$"
Use of the PID should ensure uniqueness even amongst multiple
concurrent runs of the script in a single mapset (which shouldn't
happen anyhow), and anyone using ".tmp." in a "real" map name is
asking for trouble.
> v.to.rast --overwrite input=$GIS_OPT_INPUT output=$temp1 use=attr
> column=elevation
>
> However I still get that error when I try to remove the layer/file. I
> had inferred from the g.remove man page that:
>
> g.remove rast=$temp1
>
> would remove the raster layer $temp1 but instead i get the error:
> Removing raster <39281>
> raster: couldn't be removed
"$$" evaluates to the PID of the shell running the script. "$$1" will
be that PID with a "1" appended to it. So the above error indicates
that the PID was 3928.
There doesn't appear to be anything wrong with your commands; whatever
value is chosen for temp1, I would expect "g.remove rast=$temp1" to
remove the map created by "v.to.rast ... output=$temp1", provided that
it hasn't changed in the meantime.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list