Solved

Invoke UNIX shell script from JAVA servlet using Runtime class

Posted on 2001-07-25
7
1,208 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Setting Up Local Lan Web Server 1 58
How to fix Redundant Hostnames notification from google analytic? 5 31
Android development question 2 34
ejb on wildfly 5 19
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
This video teaches viewers about errors in exception handling.

813 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

15 Experts available now in Live!

Get 1:1 Help Now