I'm curious if you could distribute a command line tool to run as a CDF file?

For example, distributing a command line tool that loads data from a database, transmogrifies it somehow, then writes it back to the database. You might not want an interface on that at all.

Is this possible?

An example of a very simple CDF script might be:

(* Open a database *)
dbconn = OpenSQLConnection[JDBC["PostgreSQL", "localhost/test"]];

(* Write something important into the database. *)
SQLInsert[dbconn, "still_alive_at",{"alive_at"}, {SQLDateTime[DateList[]]}]

(* Close connection *) 

This would be run from a cron job nightly, without interaction. Is something like this possible?

EDIT: The answer seems to be "Yes, but with significant contortions". In the real world, you should buy a Mathematica license for each production instance running your Mathematica script.

Hopefully Wolfram can remedy this situation in the future. It's a bit of a barrier to buy Mathematica for development, then ask any users to buy a Mathematica license also just to run a script. Other platforms EG: java don't charge for the runtime environement.


1 Answer 1



since version 12 is out there is also the new product "Wolfram Engine" which I think is meant exactly for this purpose. Details about that product can be found on WRIs site and in some answers on this site when searching for "wolfram engine". This is not a free product, but with every Mathematica version there is a free "developer" license for an engine. Prices for regular engines are moderate and depend on what exactly is done with them.

Old answer:

Your question has two aspects: I think WRI quite obviously wouldn't want you to do that with the free player, so they disabled the functionality which would provide a straightforward solution. As usual, there most probably are tricks to circumvent the limitations and make something similar work with the free player as well, at least if you don't insist on the direct access to PostgreSQL. But I think you most probably would violate their license for the free player if you would do that.

But even for PlayerPro, which would allow to run the code you have shown from both the technical and license point of view, I think you would need to have a setup which is only to be considered a workaround as you would have to open the front end and let it run code from a Dynamic (or from initialization cells) when the CDF document is shown on screen. Other possibilities that would directly start the Kernel in background as shown here and mentioned by Rolf might also work, but most probably also will violate at least the free player license conditions, and as Rolf als mentioned also the one of player pro.

So yes, what you ask for can be done but is certainly not a very straightforward solution for an automated and interaction free setup. At the moment (unfortunately) the most reasonable suggestion to anyone who has a professional need for such a task is to buy a full version, if you want to play around it certainly is possible to get this running with Player Pro one way or the other. Due to the fact that this most probably will violate license conditions you probably will not find good and detailed documentation about a working setup.

Another possibility you might want to take into account is to buy -- just for that purpose -- a Raspberry Pi which comes with a full valid Mathematica license and certainly could be used in the way you want, but of course provides only limited hardware performance.

  • $\begingroup$ I have no time right now to test this with the latest player(Pro), but maybe something similar to this might work. $\endgroup$ Commented Mar 4, 2015 at 1:40
  • $\begingroup$ @RolfMertig: interesting hack :-). I mentioned it (for completeness) and added some other details... $\endgroup$ Commented Mar 4, 2015 at 10:35
  • $\begingroup$ It looks like it isn't even allowed for PlayerPro, at least Andre from WRI is stating in this interesting thread here: "You cannot call the kernel from other applications, period." Of course one could talk to them. But instead of talking most people will, at least for small things, just use Java or PHP or whatever is normal. $\endgroup$ Commented Mar 4, 2015 at 14:00
  • $\begingroup$ @rolf Excellent thread Rolf. From reading things it looks like Wolfram engine when it becomes available will allow command line or server tools. Now I know. $\endgroup$
    – user4860
    Commented Mar 4, 2015 at 18:55
  • $\begingroup$ Regarding PHP/Java, my example was just that a short example so we had something to work with. My intended use is to do more than just mark a timestamp, I just needed a short example. $\endgroup$
    – user4860
    Commented Mar 4, 2015 at 19:40

Your Answer

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