Up | Next | Prev | PrevTail | Tail |
REDUCE provides limited access to the operating system via the operator system
,
which takes one argument that must evaluate to a string. It passes the content of this
string to the default shell and returns a number, which will be 0 if it succeeds
and non-zero if it fails. The output from the shell is displayed on the default
output device, which is normally the terminal. There is no straightforward way to
process this output within REDUCE. The operator system
can be useful for
operations such as copying, moving, renaming and deleting files, or for listing a
directory interactively. It is used within a few of the REDUCE packages, such as
GNUPLOT.
The correct shell syntax to use with system
depends on your operating system. On
Microsoft Windows, system
invokes the cmd.exe
shell (not PowerShell
); on other
operating systems it probably invokes bash
. Note that backslash (\
) is not an escape
character in REDUCE and so can be included in the argument to system
without any
special precautions. However, to include a double-quote character ("
) within a REDUCE
string it must be doubled.
For example, on Windows, you could use the following to delete a file called
“C:\long dir name\file.red
”
system "del ""C:\long dir name\file.red""";
whereas, on most other platforms, you could use the following to delete a file called
“/long dir name/file.red
”
system "rm ’/long dir name/file.red’";
More sophisticated use of system
is possible, but requires symbolic-mode
programming. See the REDUCE source code for examples.
Up | Next | Prev | PrevTail | Front |