[GRASS-user] Temporary files in GRASS Script

Glynn Clements glynn at gclements.plus.com
Tue Jan 5 08:10:55 EST 2010

Nikos Dumakis wrote:

> Following a few questions/emails from Glynn and Antonio regarding GRASS
> Scripting I have the following question:
> What is the main difference between Temporary files creation mentioned in
> Glynn emails:
> *tmp=tmp.myscript.$$*
> *
> *
> *And the one used in r.centroid script:*
> TMP=$$
> TMPFILE=`g.tempfile pid=$TMP`

The former creates a name with a given format ($$ is the PID of the
shell process running the script).

g.tempfile creates a temporary file at:


where <num> is chosen such that the name is unique (for g.tempfile, it
will usually be zero; if a process calls G_tempfile() multiple times,
<num> will increment).

Use the former (or something like it) if you want a name for a
temporary map, region, etc. Use the latter if you need a file.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list