【发布时间】:2010-09-13 23:11:39
【问题描述】:
如果您在 foo.m 中有 Mathematica 代码,则可以使用 -noprompt 调用 Mathematica
和-initfile foo.m
(或-run "<<foo.m")
并且命令行参数在$CommandLine 中可用(其中有额外的垃圾),但是有没有办法只使用一些数学代码,如
#!/usr/bin/env MathKernel
x = 2+2;
Print[x];
Print["There were ", Length[ARGV], " args passed in on the command line."];
linesFromStdin = readList[];
etc.
chmod 可执行并运行它?换句话说,如何像使用任何其他脚本语言(Perl、Python、Ruby 等)一样使用 Mathematica?
【问题讨论】:
标签: command-line scripting wolfram-mathematica