Skip to main content

notebooks - NotebookEvaluate with InsertResults -> True from the command line


Suppose I have a notebook template.nb like this:


enter image description here


and I want to evaluate this notebook from the command line. So I wrote this Mathematica script:


UsingFrontEnd[NotebookEvaluate["C:\\Users\\delfinog\\Desktop\\template.nb", 
InsertResults -> True]]

And I run the script like this (Windows 7):



enter image description here


C:> "C:\Program Files\Wolfram Research\Mathematica\10.2\wolfram.exe" -script C:\Users\delfinog\Desktop\mma-script.wl

My expectation is that I should be getting this:


enter image description here


but instead, I get this:


enter image description here


This is the complete output cell


Graphics[{{{}, {}, {Directive[Opacity[1.], RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6]], Line[{{2.040816326530612*^-8, 2.040816326530612*^-8}, {0.000306717908041361, 0.000306717908041361}, {0.0006134154079194566, 0.0006134154079194566}, {0.001226810407675648, 0.001226810407675648}, {0.002453600407188031, 0.002453600407188031}, {0.004907180406212797, 0.004907180406212797}, {0.009814340404262328, 0.009814340404262328}, {0.01962866040036139, 0.01962866040036139}, {0.040908355415730624, 0.040908355415730624}, {0.060777881089422996, 0.060777881089422996}, {0.08025764554305448, 0.08025764554305448}, {0.10138846501985709, 0.10138846501985709}, {0.12110911515498282, 0.12110911515498282}, {0.1424808203132797, 0.1424808203132797}, {0.16346276425151565, 0.16346276425151565}, {0.18303453884807477, 0.18303453884807477}, {0.204257368467805, 0.204257368467805}, {0.22407002874585835, 0.22407002874585835}, {0.24349292780385082, 0.24349292780385082}, {0.2645668818850144, 0.2645668818850144}, {0.28423066662450114, 0.28423066662450114}, {0.305545506387159, 0.305545506387159}, {0.32647058492975595, 0.32647058492975595}, {0.34598549413067603, 0.34598549413067603}, {0.36715145835476726, 0.36715145835476726}, {0.3869072532371816, 0.3869072532371816}, {0.40831410314276706, 0.40831410314276706}, {0.42933119182829166, 0.42933119182829166}, {0.4489381111721394, 0.4489381111721394}, {0.4701960855391582, 0.4701960855391582}, {0.49004389056450015, 0.49004389056450015}, {0.5095019343697813, 0.5095019343697813}, {0.5306110331982336, 0.5306110331982336}, {0.550309962685009, 0.550309962685009}, {0.5716599471949555, 0.5716599471949555}, {0.5926201704848412, 0.5926201704848412}, {0.6121702244330499, 0.6121702244330499}, {0.6333713334044297, 0.6333713334044297}, {0.6531622730341328, 0.6531622730341328}, {0.6725634514437749, 0.6725634514437749}, {0.6936156848765882, 0.6936156848765882}, {0.7132577489677245, 0.7132577489677245}, {0.7345508680820321, 0.7345508680820321}, {0.7544338178546627, 0.7544338178546627}, {0.7739270064072324, 0.7739270064072324}, {0.7950712499829733, 0.7950712499829733}, {0.8148053242170373, 0.8148053242170373}, {0.8361904534742725, 0.8361904534742725}, {0.8571858215114467, 0.8571858215114467}, {0.8767710202069441, 0.8767710202069441}, {0.8980072739256126, 0.8980072739256126}, {0.9178333583026043, 0.9178333583026043}, {0.937269681459535, 0.937269681459535}, {0.9583570596396369, 0.9583570596396369}, {0.978034268478062, 0.978034268478062}, {0.9783774827142147, 0.9783774827142147}, {0.9787206969503675, 0.9787206969503675}, {0.9794071254226728, 0.9794071254226728}, {0.9807799823672838, 0.9807799823672838}, {0.9835256962565057, 0.9835256962565057}, {0.9890171240349493, 0.9890171240349493}, {0.989360338271102, 0.989360338271102}, {0.9897035525072548, 0.9897035525072548}, {0.9903899809795602, 0.9903899809795602}, {0.9917628379241712, 0.9917628379241712}, {0.994508551813393, 0.994508551813393}, {0.9948517660495457, 0.9948517660495457}, {0.9951949802856985, 0.9951949802856985}, {0.9958814087580039, 0.9958814087580039}, {0.9972542657026149, 0.9972542657026149}, {0.9975974799387677, 0.9975974799387677}, {0.9979406941749204, 0.9979406941749204}, {0.9986271226472259, 0.9986271226472259}, {0.9989703368833786, 0.9989703368833786}, {0.9993135511195312, 0.9993135511195312}, {0.999656765355684, 0.999656765355684}, {0.9999999795918367, 0.9999999795918367}}]}}}, {DisplayFunction -> Identity, AspectRatio -> GoldenRatio^(-1), Axes -> {True, True}, AxesLabel -> {None, None}, AxesOrigin -> {0, 0}, DisplayFunction :> Identity, Frame -> {{False, False}, {False, False}}, FrameLabel -> {{None, None}, {None, None}}, FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}}, GridLines -> {None, None}, GridLinesStyle -> Directive[GrayLevel[0.5, 0.4]], Method -> {DefaultBoundaryStyle -> Automatic, DefaultMeshStyle -> AbsolutePointSize[6], ScalingFunctions -> None}, PlotRange -> {{0, 1}, {0., 0.9999999795918367}}, PlotRangeClipping -> True, PlotRangePadding -> {{Scaled[0.02], Scaled[0.02]}, {Scaled[0.05], Scaled[0.05]}}, Ticks -> {Automatic, Automatic}}]


So the figure is there, but it is not being displayed. Is there a way to make this work? I was thinking that the UsingFrontEnd command should avoid this situation but there seems to be something else missing.


Motivation: I am developing a report generation system that should be running automatically late at night. As the built-in template system does not work well from MathematicaScript (CASE:3432062) and using ScheduledTasks on my interactive Mathematica session has been unreliable, I am exploring using NotebookEvaluate with the InsertResults -> True option as an alternative template system.




Comments

Popular posts from this blog

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?