0

Is it possible to run a Mathematica shell script from a Wordpress page or blog post? There doesn't seem to be a plugin available or way to do this.

The script would need to take values inputted in the page (drop down menu, radio button, text box, etc.) from a Shortcode (or other straightforward input), which would be fed into the shell script at the command line, and then the results outputted into either another text box on the page, or perhaps a generated image or graph.

EDIT: I'm mostly interested in running a simple script that, given a few drop down menu/radio button inputs, would output something based on those inputs, perhaps something simple like a graphic.

EDIT: I know that a Mathematica script can be run from a shell prompt: ~$ MathKernel -noprompt -run “<<script.m”, so this, along with input parameters specified on the webpage via drop down menus, etc. would be sent to the script, execute, generate the output (a PDF), which would then be displayed on the webpage.

0

In principle PHP can do this with exec(), so WordPress can as well. You do not specify enough details, but it sounds either like form submit or Ajax request. Different implementation but in the end you will be running exec() just as well.

PS think really hard on how secure it will be and which kind of data you will allow to pass this way.

  • I see, what type of security will I need if the input(s) to the script is from drop down menus, radio buttons, check boxes, etc.? In other words, if all of the possible inputs are predetermined and fixed, what additional security can I provide to prevent attacks/hacks? – iwantmyphd Jan 27 '15 at 21:00
  • @iwantmyphd the inputs are not limited to what you mean for user to send, POST requests can be crafted with absolutely arbitrary data. You need very strict validation server–side to consider using something like this. Even then it's probably best to have someone specializing in security have a look at it. – Rarst Jan 27 '15 at 22:26
  • I guess I should have been more specific, and can add this to the post. I'd like to run a Mathematica script on my webserver, the input of which would come from the webpage, and the output of which would be sent back to the webpage. I've read that the simple shell command line: ~$ MathKernel -noprompt -run “<<script.m” will run the script, and that inputs can be specified there as well. The output of the Mathematica script generates a pdf, which I would like to be displayed on the page as soon as it is created. As far as inputs, I was hoping to use drop down menus. – iwantmyphd Mar 28 '15 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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