Hi, I have written a java class that calls an shell script.And in the java class, I am accesing the EXIT value retrured by the shell.I am able to run this from the command prompt succesfully. But,If once I make an instance of this class in a JSP and invoke the method which actually calls the shell script, my script is not working. It is giving an exit code of 127:indicating the command not found.I am unable to resolve this. I am using the tomcat web server and running it in Linux platform.I have assigned all the rigths to the file. Want to know whether tomcat has restriction imposed to call any scripts?
Overall, plz help me out. I am an newbie in this field. Thanks in advance! Sandeep
Linux/Unix systems have a notion of a search path, which the shells use to find programs when you execute something on the command line (or give a command to run via the java Execute call). It's precisely analogous to the classpath Java uses (in fact that's pretty certainly where the java designers got the idea). It's an environment variable called PATH. So suppose you've got a shell script called 'foo.sh'. When you type that on the command line it finds the script because the directory the script is in is mentioned in the PATH environment variable. Now when you try getting tomcat to run the script, lots of things are potentially different. The PATH environment variable might be different. You might be depending on the script being in your current working directory, and tomcat has a different current working directory. Or tomcat might even be running with a different user id, which doesn't have permissions to run the script (or maybe even see the script file at all). The quickest thing to try is give the fully qualified file name for the file (that is, a name that starts at the root directory /). Once that works, we can discuss how to avoid insisting that the file live in that specific place in the file system.