General Issues
1: Introduction 2: Simple example 3: Fancy example 4: Running Gri 5: Programming Gri 6: General Issues 7: X-Y Plots 8: Contour Plots 9: Image Plots 10: Examples 11: Handling Data 12: Gri Commands 13: Gri Extras 14: Evolution of Gri 15: Installing Gri 16: Gri Bugs 17: System Tools 18: Acknowledgments 19: License 20: Newsgroup 21: Concept Index |
6.5: Interaction Between Gri and Operating System
6.5.1: Using the OS from within GriGri uses the operating system internally for things like paging through help information. It also gives access to the operating system from within a gri program, with the `system ' and `open ' commands, and with the back-tic
unix notation. (Note On unix systems, `sh ' is normally
used, to get the C shell, write `system csh ... ', etc.)
The operating system may be called within Gri commands, using a
syntax borrowed from the `Bash ' unix shell. After substituting
synonyms in the commandline, Gri scans for dollar-parenthesis blocks
(e.g. `\$(system-command) ', replacing them with the textual result
of sending the indicated system-command to the OS. The replacements are
done from left to right in the commandline, starting at the deepest
nesting level.
Often the dollar-parentheis syntax is used in title commands, to
indicate the full pathname of the Gri commandfile, e.g.
gri -s8 -t '.
draw label "$(x,y)$" at 3 3 cm '. This
is an example of how TeX notation and unix shell notation collide.
Example It is a good idea to employ unix environment variables to name
directories containing data, so that Gri scripts will work unchanged
even if the data are moved (so long as the environment variables are
altered), e.g.
system ' command. This discards output. Whatever follows the word
`system ' is first scanned for synonyms (but not rpn expressions or
variables); after replacement of any existing synonyms, the line is
passed directly to the operating system. Any results are printed on the
terminal.
Frequently used system commands are `\.awk. ' (a builtin synonym
naming the awk program on your system), `head ', `grep ' and
`sed '. Examples:
6.5.2: Using Gri from within the OSThis section only applies to unix systems. Save the folowing into a file called `p' and chmod it to make it executable. It runs Gri on a named file, with the `-yes ' flag set
so that any `query ' commands are automatically answered in the
affirmative, and then displays the results in a Ghostscript window.
(USAGE: `p cmdfile.gri ')
|