Solved

Invoke UNIX shell script from JAVA servlet using Runtime class

Posted on 2001-07-25
7
1,184 Views
Last Modified: 2013-11-24
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 ?
0
Comment
Question by:wpding
7 Comments
 
LVL 3

Expert Comment

by:stimpyjcat
ID: 6321894
You might try dumping the environment to examine exactly how the user and group are set for the shell script, e.g. invoke a new shell script that saves the output of $USER, $UID, $GID, groups, etc.

It may be that the servlet itself is running under different privileges or user info than you expect.

0
 

Author Comment

by:wpding
ID: 6336427
I did. the shell script was executed by user id nasusr, group nas when invoke thru web.
0
 
LVL 3

Expert Comment

by:graf27
ID: 6337075
use your webservers CGI to execute the script, not the servlets Runtime (!!).

So you have a URL to execute the Script.

Inside your servlet, you can execute the URL with all the needed parameters and handle the response.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:wpding
ID: 6342951
Due to business rule constraints, script not store in the <NES doc> base directory, it stored in different file system.
0
 

Expert Comment

by:CleanupPing
ID: 9061954
wpding:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9208309
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[paqed and points refunded]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 9403439
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now