mathematica从命令行启动前端和评估笔记本 [英] mathematica start front end and eval notebook from command line
问题描述
是否有一种方法可以从(Windows)命令提示符下启动mathematica前端(GUI),并将其评估为笔记本,而无需进一步的用户操作?
Is there a way to start up a mathematica front end (GUI) from a (Windows) command prompt and have it eval a notebook without further user action?
即使mathematica.exe带有-run和-initfile选项,它们也无法正常工作
就像他们对math.exe所做的一样. (例如,运行"<
even though mathematica.exe takes the -run and -initfile options they dont work the same as they do with math.exe. (-run ''<<file.m'' wants to open a file named ''<<file.m'' for example)
谢谢.第一个答案看起来很有希望,但是我得到了 FrontEndObject :: notavail 前端不可用
Thanks. The first answer looks promising, however I get FrontEndObject::notavail A front end is not available
(顺便说一下,每个文档都是"UseFrontEnd".)
(per docs it is "UseFrontEnd" by the way.)
也许是路径问题,但是即使在设置$ FrontEndLaunchCommand之后也没有任何乐趣.
Perhaps a path issue, however even after setting $FrontEndLaunchCommand no joy..
关于:初始化单元格-这个简单的答案似乎完全可以满足我的需要,除了您想运行初始化.."导航框.如果有一个somplace选项可以自动启动内核并运行初始化单元,那将是非常有用的.
Re: Initialization Cell -- that simple answer would seem to do exactly what I need excepting for the "do you want to run initialization.." nag box. If there is an option somplace to automatically start a kernel and run initialization cells that would be really useful to know.
我正在运行6.0.
推荐答案
啊哈!!!
Needs["JLink`"];
$FrontEndLaunchCommand="C:\\Program Files\\Wolfram Research\\Mathematica\\6.0\\Mathematica.exe";
ConnectToFrontEnd[];
UseFrontEnd[Module[{}, ...
跟进..以确保完整性---上面的$ FrontEndLaunchCommand导致GUI出现,因此您可以观察评估(我想要的).默认是在后台服务器模式下运行前端,因此您必须使用前端功能,但看不到它运行.
follow up..for completeness --- the above $FrontEndLaunchCommand causes the GUI to come up so you can observe the evaluation (What I wanted). The default is to run a front end in a background server mode, so you have acess to front end functions but cant see it run.
这篇关于mathematica从命令行启动前端和评估笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!