This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Runtime.getRuntime().exec() from JSP page  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page, there I want to execute the following shell script with the exit codes for 0 and 1 for success and fail respectively thru Runtime.getRuntime().exec().



The exection is success while execting the shell script alone and also thru a stand alone Java program. But While calling this shell script from the JSP, I am always getting the negative response, that is the Process.exitValue() returns always 1.

Any suggestions and help appreciated !!!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

if [ -f "help.txt" ]



That would appear to depend on the "current" directory. You have no control over the current directory in the servlet environment.

Bill
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thats how I have done.I am running an exe file to convert dms to tiff.I have used absolute path.


Hope this will hepl


[BSouther: Added UBB CODE tags]
[ April 24, 2007: Message edited by: Ben Souther ]
 
Preeti Arora
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thats how I have done.I am running an exe file to convert dms to tiff.I have used absolute path.

String[] cmd = { "C:\\imaging\\kman_DMStoTiff\\bin\\kman_DMStoTiff.exe", "C:\\imaging\\test.dms", "C:\\jboss-4.0.5.GA\\server\\default\\deploy\\documents.war\\pal1.tiff" } ;
Process p = Runtime.getRuntime().exec(cmd) ;
BufferedReader in =new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
p.destroy();

Hope this will help
 
Manimekala Velautham
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah...I forgot to think this way...this fixed my problem and is working fine. Thanks
 
You showed up just in time for the waffles! And this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!