Discussions

Web tier: servlets, JSP, Web frameworks: servlets and shell scripts

  1. servlets and shell scripts (5 messages)

    Hi All,

    I am trying a wierd combination of using shell scripts to run jobs on server. I need some parameters to be passed to scripts from HTML form, I am trying to use servlets for this. Can one advice how to pass parameters to shell script using servelts ans HTML form.

    Thank you,
    Ashish

    Threaded Messages (5)

  2. Ashish,

    If you are using Oracle as a Database, it is possible to do what you want by making the Servlet invoke an External Proc which in turn can kick off a Shell script.

    If you are not Using Oracle then sorry for this answer.
  3. It shouldn't be too hard. You'll have to fork a process with Runtime.getRuntime().exec(...). Read your params from the request, build your command-line, and feed it to Runtime.exec().

    Andy
  4. Thanks Andy,

    Reading parameters from request is clear and so is for the script to read command line parameter. Can you please elaborate on how to build a command line.

    Thanks
    Ashish
  5. just a comment to compliment this... pass parameters as an array of strings... rather than a complete string, the first element is the actual command followed by the arguments... its faster that way....so Runtime.getRuntime().exec(cmdArray);
  6. Thanks Aditya for the comment.
    Can you giude me where can I get additional related details?

    -ashish
    ashish@sgi.com