-1

I am using HTMl to develop a GUI where in I want to give a call to a function existing in .sh file.

Can any one please suggest suitable option as I tried to call function in different ways but didn't worked out.

  • What will be the steps for above to execute? – Prajakta Shinde Jan 21 '15 at 04:37
  • 3
    Do you mean a Unix shell-script file? And is it on the server or the client? – Dawood ibn Kareem Jan 21 '15 at 04:37
  • 1
    Hope you have checked these: http://stackoverflow.com/questions/27012272/how-to-run-a-shell-script-from-an-html-page http://www.cyberciti.biz/tips/executing-linuxunix-commands-from-web-page-part-i.html http://stackoverflow.com/questions/6235785/run-a-shell-script-with-an-html-button – Pramod Karandikar Jan 21 '15 at 04:39
  • You tagged Java. Probably you have Java code in the back end. Run the shell script there. Call the Java function from HTML through From submission or some AJAX call. – Coder Jan 21 '15 at 04:52
  • Yes. I have Java code in the back end. I will try for this. – Prajakta Shinde Jan 21 '15 at 05:42
  • hi All,I have tried for below code ProcessBuilder pb = new ProcessBuilder("Tasks/SA Autodeployment/copyScript.sh"); Process p = pb.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; while ((line = reader.readLine()) != null) { System.out.println(line); } but getting this exception Cannot run program "/Tasks/SA Autodeployment/copyScript.sh": CreateProcess error=193, %1 is not a valid Win32 application – Prajakta Shinde Jan 21 '15 at 06:44

1 Answers1

0

You cannot do this from HTML. HTML describes what a page looks like; it doesn't "execute" anything.

You might be able to translate your shell script into JavaScript, which can be embedded in an HTML page, depending on what the shell script does.

If you have a web server, CGI is a protocol (not a network protocol) which allows the web server to run specially-written executables (including scripts) in response to requests to certain web addresses. You can then include a form that submits to an address that triggers your script, or send the request from JavaScript.

user253751
  • 57,427
  • 7
  • 48
  • 90