Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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? – Sjoerd C. de Vries May 17 '14 at 19:35

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

share|improve this answer
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 -- " – mlainz May 18 '14 at 18:06
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. – Johu May 18 '14 at 19:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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