Invoke UNIX shell script from JAVA servlet using Runtime class
Posted on 2001-07-25
My application running under HP UNIX 11 environment using NES4.0 and NAS4.0. One of the function in web is to execute a UNIX shell script to perform some adminstration task. To invoke the unix shell script, Runtime class has been used in servlet, method exec used to call this shell script.
My problem is, due to the security permission, this shell script was created under user id user1 and group grp1. However, NAS and NES are installed using different id and grp, e.g. id=nasusr, grp=nas. Shell script can only allow to open the permission to rwxr-x--- (up to group level).
In order to allow user nasusr to execute this script file, user nasusr was created under primary group nas and as member of grp1 also.
In unix prompt, login as nasadm user and execute this shell script, correct result obtained. However, if invoke this thru JAVA servlet using Runtime.exec() method, error "shell script can not execute".
If change the permission of this shell script to rwxr-xr-x, and execute it using Runtime.exec(), correct result can be obtained.
It seems to be by adding userid nasusr to group grp1 (not primary group) doesn't recognised by this java Runtime.exec() method.
Any recommendation to solve this problem ?