If you look at this #!/usr/local/bin/math8.0.4/MathematicaScript -script $HistoryLength=0; $pwf=FileNameJoin[{NotebookDirectory[],FileBaseName[NotebookFileName[]]}]; $pwf = "test"; $parameterfile=StringJoin[$pwf,".dat"]; Print[$pwf]; Print[$parameterfile]; Print[$InputFileName]; you will see that the Print statements work just fine - What requires the FrontEnd are the `Notebook*XY*[]` functions and since this is a script and not a notebook these are not avaiable. So you'd need to replace those. You could, for example, use `$InputFileName` and derive the information from that instead. The last print will have the file name. Note that this is not an interactive session; then `$InputFileName` is ""