Results 1 to 8 of 8
- 06-06-2011, 10:16 AM #1
Member
- Join Date
- Jun 2011
- Posts
- 7
- Rep Power
- 0
How to invoke shell script from JSP page
Hi Friends,
I am a beginner to java/jsp. I have one shell script, that needs to be invoked from my jsp page. Here is the code in my page - testjava.jsp :
and my test.ksh contains the below code :Java Code:<%@page language="java" %> <%@page import="java.util.*" %> <html> <head> <% String unixCommand = "sh test.ksh"; Runtime rt = Runtime.getRuntime(); rt.exec(unixCommand); System.out.println("Print Test Line."); %> </head> <body> </body> </html>
When i call this page from my website "http://132.17.34.101:7777/tools/testjava.jsp" it is showing blank and the shell script is not executed.Java Code:echo ' Done successfully ' > testfile.txt
Please help me out .
Regards,
Rajesh
- 06-06-2011, 10:22 AM #2
- 06-06-2011, 11:13 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 7
- Rep Power
- 0
My expected out put is this:
When i copy this link "http://132.17.34.101:7777/tools/testjava.jsp" in browser and hit enter then it should call my shell script and testfile.txt should be created on that directory (the directory where the jsp page is created in unix box).
Also , pls let me know whats wrong in that code?Last edited by rajesh4851; 06-06-2011 at 11:15 AM.
- 06-06-2011, 11:15 AM #4
Who tell it you? it will be created in folder there you run your web service. for example tomcat/bin/the directory where the jsp page is created in unix boxSkype: petrarsentev
http://TrackStudio.com
- 06-07-2011, 03:27 AM #5
Member
- Join Date
- Jun 2011
- Posts
- 7
- Rep Power
- 0
Its working when i give complete path prefix to my shell script like this...
String unixCommand = "/u04/..../sh test.ksh";
Thanks to all.
- 10-07-2011, 01:35 PM #6
Member
- Join Date
- Oct 2011
- Posts
- 1
- Rep Power
- 0
Re: How to invoke shell script from JSP page
And the File testfile.txt can be found under tomcat log folder - true when i ran the same Script
- 10-10-2011, 09:29 AM #7
Member
- Join Date
- Jun 2011
- Posts
- 7
- Rep Power
- 0
Re: How to invoke shell script from JSP page
Thanks Manish..!!
- 01-09-2012, 10:02 AM #8
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
Problem to invoke webbeans from JSF page
By gscoelho in forum JavaServer Faces (JSF)Replies: 0Last Post: 02-26-2011, 04:41 PM -
Java Applet Shell script
By karthikm897 in forum Java AppletsReplies: 5Last Post: 08-18-2009, 04:42 AM -
Can we use XSL languages to generate Shell script?
By balakrishna in forum XMLReplies: 1Last Post: 02-26-2009, 07:46 AM -
How can i create an error page in jsp and invoke it ...?
By vrk in forum Java ServletReplies: 0Last Post: 02-16-2009, 08:05 AM -
How to generate auto shell script using java..
By balakrishna in forum Advanced JavaReplies: 8Last Post: 12-30-2008, 06:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks