I'm running Mathematica on OS X and I want to create an Automator action that converts spreadsheet files. I have written this script:

#!/usr/local/bin/MathematicaScript -script

FORMATS = {"csv", "tsv", "dat", "xls", "xlsx", "odf"};
files = Rest @ $ScriptCommandLine;
data = Import /@ files;
{ext, delete} = 
   DialogNotebook @ {
     TextCell["Choose output format:"], 
     PopupMenu[Dynamic[x], FORMATS], 
     Row @ {Checkbox[Dynamic[y]], TextCell["Delete original files"]}, 
     Row @ {CancelButton[], DefaultButton[DialogReturn[{x, y}]]}
newNames = (FileNameJoin@{DirectoryName[#], FileBaseName[#]} <> "." <> ext)& /@ files;  
MapThread[Export, {newNames, data}];
If[delete, DeleteFile[files]];

When I run it, I get this error message when running DialogInput:

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

Is there any work-around, or should I try a different approach?

  • 2
    $\begingroup$ You're indeed using a lot of functions that require the FrontEnd. Not sure why you think you could run that without FrontEnd. If you want this kind of interactivity why don't you simply use a notebook? $\endgroup$ Commented May 17, 2014 at 19:35

1 Answer 1


You can solve the issue by wrapping your code with UsingFrontEnd[].

  • $\begingroup$ I have both the script and the file in my home directory. If I run "./myScript data.csv" in terminal, I get this error "MathLink`Synchronized::noshare: -- Message text not found -- " $\endgroup$
    – mlainz
    Commented May 18, 2014 at 18:06
  • $\begingroup$ Sry, but it seems a different platform specific problem. When you run UsingFrontEnd[NotebookPut[Notebook[{Cell[Text["Test"]]}]]] in your script without the UsingFrontEnd you get the FrontEndObject error. You don't get any errors with. I do not know about the MathLink problem. $\endgroup$
    – Johu
    Commented May 18, 2014 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.