Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to invoke external program

 
Waldle Cai
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
Is there any way that I can invoke an external program or shell command under unix? Thanks a lot.
Regards
Waldle
 
Elisabeth Van
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some code that I've used to run an executable and pass in command line arguments.

Runtime rt = Runtime.getRuntime();
Process prcs = rt.exec("/prd1/exe/udms mod 4rw salary gen con <infile.txt >/dev/null");
prcs.waitFor();

In this example, udms is the executable, the rest of it is command line arguments particular to this application. Hopefully this will help you get started. You're also going to have to handle IOException and InterruptedException.
Hope this helps.
 
Waldle Cai
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your prompt reply!! it's exactly what i wanted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic