• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with running a shell script from the JSP

 
Harish Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am having a problem when I am trying to execute the shell script from my JSP file.
my code:
<%
Runtime r = Runtime.getRuntime();
Process p = null;
String cmd[] = {"/bin/sh", "-c" , "/root/cfserver.sh"};
p=r.exec(cmd);
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line=br.readLine())!=null)
{ out.println(line); }
p.waitFor();
%>
there is no error shown its calmly navigating to next page without executing the "cfserver.sh" file. The case is something like once the user logs in the site a server should automatically start. Please let me know what is wrong with the code i mentioned above and also if you have anyother ways to go on with this.
URGENT!!!
thank you,
Harish.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!