Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Run a shell script from a servlet?

 
vishal goyal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please let me know how to run a shell script from a servlet. Also please let me know how a servlet can get into the server to run the shell script as it would require the id-password for that.
Thanks and regards,
vishal
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18214
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mechanism is exactly the same as for standalone java. You get the JavaRuntime object and invoke its exec() method. The security context is that of the servlet server - anything else would most easily be acomplished by calling a glue script in that context that suexec's the actual script.
 
vishal goyal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
Thanks for help.
Still, some more help needed. Please give me some code snippet demonstrating this solution.
Am able to use exec() but am not aware of glue script or suexec.
Thanks and Regards,
vishal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic