g.tempfile.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <h2>DESCRIPTION</h2>
  2. <em>g.tempfile</em>
  3. is designed for shell scripts that need to use large temporary files.
  4. GRASS provides a mechanism for temporary files that does not depend on
  5. /tmp. GRASS temporary files are created in the data base with the assumption
  6. that there will be enough space under the data base for large files.
  7. GRASS periodically removes temporary files that have been left behind
  8. by programs that failed to remove them before terminating.
  9. <p>
  10. <em>g.tempfile</em>
  11. creates an unique file and prints the name. The user is required to provide
  12. a process-id which will be used as part of the name of the file.
  13. Most Unix shells provide a way to get the process id of the current shell.
  14. For /bin/sh and /bin/csh this is $$.
  15. It is recommended that $$ be specified as the process-id for
  16. <em>g.tempfile</em>.
  17. <h2>EXAMPLE</h2>
  18. For /bin/sh scripts the following syntax should be used:
  19. <div class="code"><pre>
  20. temp1=`g.tempfile pid=$$`
  21. temp2=`g.tempfile pid=$$`
  22. </pre></div>
  23. For /bin/csh scripts, the following can be used:
  24. <div class="code"><pre>
  25. set temp1=`g.tempfile pid=$$`
  26. set temp2=`g.tempfile pid=$$`
  27. </pre></div>
  28. <h2>NOTES</h2>
  29. Each call to <em>g.tempfile</em>
  30. creates a different (i.e. unique) name.
  31. Although GRASS does eventually get around to removing
  32. tempfiles that have been left behind, the programmer should
  33. make every effort to remove these files. They often get
  34. large and take up disk space. If you write /bin/sh scripts,
  35. learn to use the /bin/sh <em>trap</em> command. If you
  36. write /bin/csh scripts, learn to use the /bin/csh
  37. <em>onintr</em> command.
  38. <h2>AUTHOR</h2>
  39. Michael Shapiro,
  40. U.S. Army Construction Engineering
  41. Research Laboratory
  42. <p><i>Last changed: $Date$</i>