My mathematica script is as follows:
#!/usr/local/bin/MathematicaScript -script
$HistoryLength=0;
$pwf=FileNameJoin[{NotebookDirectory[],FileBaseName[NotebookFileName[]]}];
$parameterfile=StringJoin[$pwf,".dat"];
Export["testcase.dat", {0.333, 100,0, 0, 35.1, 7.02, 0, 2, 1, 5, 10000}];
Export[$parameterfile, {0.333, 100, 0, 0, 35.1, 7.02, 0, 2, 1, 5, 10000}];
It is also uploaded here
All it does is creates a file name from the NotebookDirectory
and NotebookFileName
and saves a bunch of data {0.333, 100,0, 0, 35.1, 7.02, 0, 2, 1, 5, 10000}
to file with generated filename.
It runs fine with the front end.
However, it doesn't run from a unix terminal which defeats the purpose of having this script.
The error that I get is:
> FrontEndObject::notavail: A front end is not available; certain
> operations require a front end.
>
> FrontEndObject::notavail: A front end is not available; certain
> operations require a front end.
>
> StringJoin::string: String expected at position 1 in
> FileNameJoin[{NotebookDirectory[$Failed],
> FileBaseName[NotebookFileName[$Failed]]}]<>.dat.
>
> Export::chtype: First argument
> FileNameJoin[{NotebookDirectory[$Failed],
> FileBaseName[NotebookFileName[$Failed]]}]<>.dat is not a valid file
> specification.
Am I to understand that I will HAVE to use the front end for when I have StringJoin
operations?
The reason I find StringJoin
useful is that I have 150 different cases varying in parameters and easily identified by file name. If I can have a script to run all these mathematica cases, it would save a lot of trouble.
Any help would be appreciated.