设置Mathematica命令行退出代码

时间:2016-02-09 10:22:05

标签: bash wolfram-mathematica

我使用或多或少的方法从命令行运行Mathematica:

Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr

我只是想知道;如何控制命令行看到的退出代码?例如,我通过Bash脚本中的循环多次运行我的Mathematica代码,如果看到退出(FAIL),我想终止循环,即返回代码大于0.也就是说,我想要如果发生了不好的事情,请尽早终止Mathematica代码,并将此信息传递给调用脚本,以便我可以中止循环。我认为它一定是可能的,但我在文档中没有看到关于返回代码的任何信息。退出[]。

1 个答案:

答案 0 :(得分:3)

等等,我只是愚蠢Exit []的文档确实说了以下内容:

“在大多数计算机系统上,Exit [n]可用于将整数退出代码n传递给操作系统。”

https://reference.wolfram.com/language/ref/Exit.html