my dog learned polymorphism*
The moose likes Java in General and the fly likes How to execute commands or sh files from JAVA in Solaris Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to execute commands or sh files from JAVA in Solaris" Watch "How to execute commands or sh files from JAVA in Solaris" New topic
Author

How to execute commands or sh files from JAVA in Solaris

Sundeep Mohanty
Greenhorn

Joined: Jan 28, 2003
Posts: 7
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

Joined: Oct 10, 2002
Posts: 77
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to execute commands or sh files from JAVA in Solaris