Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing script as secondary group

Status
Not open for further replies.

philipose

Programmer
Dec 24, 2003
137
US
Hi,
I have a user id myid on an AIX 5.3 server with primary group group1 and secondary group group2. I want to execute a shell script script1 as if I am executing by an id with a user id in primary group group2.

If I have to execute script1 from the shell, i can execute the command
newgrp - group2
and run
sh script1
to get the desired results

But if script1 was called from another script, say callscript, I was not able to put the below 2 lines in callscript and get the same results

newgrp - group2
sh script1

Any ideas ??
Thanks
Philipose
 
The man page of newgrp says that:

Note: The newgrp command does not take input from standard input and cannot be run from within a script.

Any idea how I can do the equivalent via a script ?

Thanks
Philipose
 
I think I can do this by setting the gid on the callscript and assigning the desired group ownership to callscript. Let me give that a try

Philipose
 
You'll need a c-program wrapper around the script. Shell scripts don't follow suid/sgid bit settings like real executables do.

sudo perhaps?


HTH,

p5wizard
 
Bummer. I dont have sudo rights and prefer to keep this within shell scripts. I am hoping a better soln will prevail.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top