This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with running a shell script from the JSP  RSS feed

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!