This is a simple example of writing to and reading from a text file:
(1) -> f1: TextFile := open("/tmp/test","output")
writeLine!(f1,"abcdefg")
close! f1
f2: TextFile := open("/tmp/test", "input")
l := readLine! f2
output l
abcdefg
close! f2
Here is a system command. It display how many files there are in the default current directory where Axiom is run.
)set output algebra on
systemCommand("system ls | wc")
108558 108571 3471506
Please do not try to list the complete contents of this directory! If you do, MathAction will appear to hang.
Here is a shorter list of files that works ok:
)set output algebra on
systemCommand("system ls .. > /tmp/test")
f2: TextFile := open("/tmp/test", "input")
(10) "/tmp/test"
while not endOfFile? f2 repeat s := readLine! f2 output s
Data.fs Data.fs.index Data.fs.lock Data.fs.old Data.fs.tmp LatexWiki README.txt Z2.lock Z2.pid graphviz.pdf.xml pts revisions.xml x.png zopectlsock
close! f2
(12) "/tmp/test"
Here is an example of how to call a polymake constructor. Notice that you must use the full path name.
)set output algebra on
systemCommand("system /usr/local/polymake/bin/cube /tmp/cube4.poly 4 2>/tmp/cube4.stderr >/tmp/cube4.stdout")
Here is the standard output of the command (if any):
systemCommand("system cat /tmp/cube4.stdout")
Here is the error output of the command (if any):
systemCommand("system cat /tmp/cube4.stderr")
sh: 1: /usr/local/polymake/bin/cube: not found
Now display the contents of the file that was created:
f2: TextFile := open("/tmp/cube4.poly", "input")
>> Error detected within library code:
"File is not readable""/tmp/cube4.poly"
systemCommand("system /usr/local/polymake/bin/cross /tmp/c4.poly 4")
sh: 1: /usr/local/polymake/bin/cross: not found
systemCommand("system cat /tmp/c4.poly")
cat: /tmp/c4.poly: No such file or directory