6

我想在 Mathematica 中编写命令行脚本,但似乎找不到Argv[i_Integer]类似的函数。(否则文档非常棒。)

4

3 回答 3

6

假设您使用MathematicaScript for scripting,似乎$ScriptCommandLine是您需要的变量。如果您使用,否则它将是$CommandLinemathMathKernel -script

其他相关讨论:MMA 工具包中的一个相当老的一个和一个。

于 2011-11-01T20:52:48.440 回答
4

$CommandLine适用于 Mathematica、MathematicaScript、MathKernel 和数学。

args.ma:

#!/usr/bin/env MathKernel -script

Print[$CommandLine]

例子:

$ ./args.ma a b c
{"MathKernel", "-script", "./args.ma", "a", "b", "c"}
于 2011-11-02T17:18:34.427 回答
1

我喜欢使用环境变量传递东西:

http://reference.wolfram.com/mathematica/ref/Environment.html

于 2011-11-02T01:07:36.400 回答