Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

shell scripts in solaris frm java

Hi Guys,

How to run the shell scripts from java under solaris? Following is the code what i have written..

Process p1 = Runtime.getRuntime().exec("/opt.sh");
p1.waitFor();

This is working perfectly under Linux OS. But got confused why it is not running under solaris..Can anybody please give me suggestions?

The error am getting is..

java.io.IOException: /export/home0/oracle/Testing/Day_12122006/SS7/opt.sh: cannot execute
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:54)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)

Thanks in advance..
[872 byte] By [zeal79] at [2007-11-11 10:00:39]
# 1 Re: shell scripts in solaris frm java
Make sure that, you have given execute permission for ./opt.sh
otherwise try giving
Runtime.getRuntime().exec("sh ./opt.sh")
or
Runtime.getRuntime().exec(new String []{"sh","./opt.sh"})
sudheerprem at 2007-11-11 22:32:11 >