• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling a shell script or a batch file

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i have a web application written in struts in deployed on tomcat. i want to provide use with a button on my UI, so when the button is pressed it calls shell or a bat file which will start an independent java program which will do some file export stuff. May i know how can i can i execute the shell or the batch srcipt.
Any idea
Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rashid,
To call an operating system shell script or batch file, you use the Runtime.exec() API. In your case, you can just call the Java program:

There's no reason to introduce additional complexity since you are calling other Java code.

With either approach, you may want to start the other program in a new Thread if you want it to be asynchronous.
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne,

The other thing i wanted to know is that i dont want user to start duplicate process. So for Example if the user already clicked the file and the file generation is in process, i dont want to start one more process when i the user accidently clicks on the button. May i know how can i check for the process whether it is already running

Thanks
Rashid
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic