Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am not able to call a shell script program from javascript(for example if someone will click a button in webpage then a script will run and will throw some output)???

share|improve this question

1 Answer 1

Because of security concerns, you cannot do this like you can e.g. call a binary program from a shell script, some program from Python using subprocess.check_output() or any of the other mechanisms in various programming languages.

If you want this kind of functionality, the way to go is to:

  1. run a small webserver local, i.e. on the machine
  2. allow javascript to access this (some newer versions browsers block certain calls like this)
  3. have the click of the button invoke some javascript that then accesses the local webserver to carry out the function that you need.

I have used this mechanism to allow printing, on the local machine, of multiple selected Word documents. The submit of the list of documents is redirected to the local webserver (using XML-RPC) that then retrieves the documents, and starts Word in batch mode to print them all.

share|improve this answer

Your Answer

 
discard

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.