Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to execute commands or sh files from JAVA in Solaris

 
Sundeep Mohanty
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to execute some commands and shell script from java program in Solaris OS, I tried in the follwoing manner, but its not working.
Pls help me.
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("/bin/sh -c /app/xchanging/xasRND/Testing.sh");
or
Process p = runtime.exec("/app/xchanging/xasRND/Testing.sh");

Regards,
Sundeep.
 
Ulas Ergin
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Runtime.exec("sh myscript") but you need to exhaust out and error streams
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
is a great resource.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic