Hi Jitesh,

jithesh wrote:
Thanks for your response.  I have given the following instruction to the
code. when i executes it displays the user name as 'root'.

i am getting the exception 'java.io.IOEXception:/opt/gsscript/gs.sh not
found'
Well, the IOException is telling you that your java code can't find the shell script. Some reasons I can think of for that could include:

- the path is wrong - but I'm sure you've checked that;
- the path includes a symlink that isn't visible to the user (less likely with root, but still possible); - your jvm and/or web server and/or web application has a SecurityManager configured that prevents access to the path.

I don't know much about SecurityManager, I just know it can be used to limit access from a Web Application Server to the file system it runs in. I also don't know much about Websphere since I've not worked with it for about 6 years, but you may want to look up its documentation for SecurityManager.

I would point out that it may be time to review what you are trying to do. Running a web application server with root privileges is normally considered dangerous. I know from experience that working with Runtime is difficult. It is not well documented from a "functionality" viewpoint and it holds lots of traps for the unwary.

You may find it easier (and safer) to transfer your shell script's functionality into Java code than to try and use Runtime. I believe Java's image libraries are pretty good these days.

Rob Hills wrote:
jithesh wrote:
   i am using appfuse 1.9.4 for building my web app. my java class
executes
a shell script that creates an image file to the destination path. But
when
run the application the shell script is not getting executed. My code to
call the shell script is given below

     Runtime runtime = Runtime.getRuntime();
runtime.exec("/opt/gsscript/gs.sh").waitFor();
If i execute the shell script from the terminal the image is getting
generated.

I am using websphere 1.1 application server for deployment. Can any one
suggest the solution for this problem. My application is having root
privileges.
Are you certain that Websphere is running as root? I understand that running a web server as the root user creates quite a substantial security risk and should be avoided at all costs. If you haven't done so already, try printing the output of System.getProperty("user.name") to a log file and that will tell you what user your system is running as.

Then, what errors are you getting when you run your script? What output are you getting from the output and error streams (as discussed earlier: http://www.nabble.com/Re%3A-shell-script-in-java-p13489527s2369.html)? What return value are you getting from your script?

HTH,

Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to