Hi, I am not an expert with Mathematica... As a cluster administrator, I am trying to help users to run their applications via the terminal.
A very simple notebook file (.nb) is here:
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 10.3' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 1918, 77]
NotebookOptionsPosition[ 1570, 60]
NotebookOutlinePosition[ 1915, 75]
CellTagsIndexPosition[ 1872, 72]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
RowBox[{
RowBox[{"a", "=", "3"}], ";"}]], "Input",
CellChangeTimes->{{3.67245858111902*^9, 3.6724586091944237`*^9}}],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"Solve", "[",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"x", "^", "2"}], "+",
RowBox[{"a", " ", "x"}], "+", "1"}], "==", "0"}], ",", "x"}],
"]"}]], "Input",
CellChangeTimes->{{3.6724585110847526`*^9, 3.672458525710531*^9},
3.672458572665449*^9}],
Cell[BoxData[
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"x", "\[Rule]",
RowBox[{
FractionBox["1", "2"], " ",
RowBox[{"(",
RowBox[{
RowBox[{"-", "3"}], "-",
SqrtBox["5"]}], ")"}]}]}], "}"}], ",",
RowBox[{"{",
RowBox[{"x", "\[Rule]",
RowBox[{
FractionBox["1", "2"], " ",
RowBox[{"(",
RowBox[{
RowBox[{"-", "3"}], "+",
SqrtBox["5"]}], ")"}]}]}], "}"}]}], "}"}]], "Output",
CellChangeTimes->{{3.67245857460305*^9, 3.672458601115856*^9}}]
}, Open ]]
},
WindowSize->{759, 601},
WindowMargins->{{Automatic, 295}, {24, Automatic}},
FrontEndVersion->"10.3 for Microsoft Windows (64-bit) (October 9, 2015)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 134, 3, 31, "Input"],
Cell[CellGroupData[{
Cell[717, 27, 290, 9, 31, "Input"],
Cell[1010, 38, 544, 19, 46, "Output"]
}, Open ]]
}
]
*)
(* End of internal cache information *)
From the GUI, the user selects all cells (CTRL+A) and then evaluates cells (SHIFT+ENTER). Now, I wrote a simple .m file which contains.
UsingFrontEnd[
file = "/home/mahmood/solve.nb";
targetnotebook = NotebookOpen[file];
SelectionMove[targetnotebook, All, Notebook];
SelectionEvaluate[targetnotebook];
NotebookSave[targetnotebook];
NotebookClose[targetnotebook];
]
and the command I run is
mahmood@cluster:~$ $MTH/Executables/WolframKernel -initfile solve.m
Mathematica 10.3.1 for Linux x86 (64-bit)
Copyright 1988-2015 Wolfram Research, Inc.
In[1]:=
However, it stuck and never returns to the command prompt Any idea about that?