Runtime.exec problem

Hi,

I created a .sh file called run.sh and it's located in the following path:

/opt/orod

it must execute a class was locatated in

/opt/orod/com/carriex

I want to run it via a web page (I use JSF in web tier), so, I coded a method in a bean and placed in the followin path

/opt/tomcat/webapps/carriex//WEB-INF/classes/com/carriex/web/ui/beans

the part of my method is like this:

. . .

String shDir = "/opt/orod";

Runtime runtime = Runtime.getRuntime();

Process proc = runtime.exec("./run.sh" + " " + shDir);

. . .

but, when I call this method by cliking on the button in a jsp, I have got the below exception:

Caused by: java.io.IOException: java.io.IOException: ./run.sh: not found

However, when I've changed it to this,

Process proc = runtime.exec("/bin/sh" + " " + "./run.sh" + " " + shDir);

I dont get any errors, but run.sh file doesnt work!!!!

Do you have any suggestion?

Orod Semsarzadeh

null

[1031 byte] By [orodsema] at [2007-11-26 16:03:03]
# 1

Should not this

Process proc = runtime.exec("./run.sh" + " " + shDir);

actually be

Process proc = runtime.exec("/opt/tomcat/webapps/carriex//WEB-INF/classes/com/carriex/web/ui/beans/run.sh" + " " + shDir);

You can only use ./run.sh if the current working directory contains the run.sh script.

sabre150a at 2007-7-8 22:24:54 > top of Java-index,Java Essentials,Java Programming...