newgrp in a script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers newgrp in a script
# 8  
Old 01-08-2004
I see that you don't get what I want to do... sorry for my expression in english !!

My project TOTO have a primary group B and a secondary group A
My account have a primary group A and a secondary group B
My colleague C1 has a primary group A and a secondary group B
My colleague C2 has only a primary group A

When I work for TOTO I'd like to have right to write on, from my own account.
Same for my colleague C1. C2 is able to read but not write on TOTO.

For the moment, I have a script wich check if you are authorized to work on the project. If 'yes' the umask is set to 002 and I do newgrp and so on. So that each created file is AUTOMATICALLY created with the group B.

I don't have 'root' permissions. So I can not execute 'chgrp' on the account TOTO for all the files don't belong to me. My application create a lot of files/directory so it is hard to do 'chgrp' each 5 minutes and more hard to request to each user to do the same!!

I try to forget newgrp but... I can't !!
# 9  
Old 01-08-2004
If you need help from your system administrator, get it! System admins are paid to help people like you. Still, you can probably handle this without help....

It is hard to set set the sgid bit on a directory with Solaris. But it can be symbolically.

mkdir somedir
chgrp groupb somedir
chmod g+s somedir

Now every file created in somedir will get a group of groupb.

If you can write to a directory, you really can change the group of a file in that directory:
cd somedir
cp somefile somefileNEW
rm somefile
mv somefileNEW somefile
You seem to be able to write scripts, this should be a 5 minute job.

You need to get everyone to "umask 002". Ask them to put it in their .profiles.
# 10  
Old 01-08-2004
I ask my local support but I have no reply...

I've made a script which do the copy and then the remove of directories of the project account. I works well. I just have to launch it one or two times a day.

Thanks for your help.
# 11  
Old 01-08-2004
Notice the "chmod g+s dir" trick. Once you do that, all new files get the correct group automatically.

You should not need to rerun your script ever. You just run it once to get the old files right.
# 12  
Old 01-08-2004
Goog trick !!
Thanks !!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

2. Solaris

Newgrp fails on only 1 group

I have a handful of users who can't 'newgrp' to one specific group from Solaris 9 and 10 nodes and always get this prompt: newgrp: Password: We never get prompted by 20+ other groups and this group never prompts for a password from Red Hat Linux nodes. Authentication comes from AD and there's... (4 Replies)
Discussion started by: rnae20
4 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

How to set up newgrp on .profile?

Hello all, I am having an issue setting up an environment on .profile. I want to set up my .profile in that way that everytime I login to the host, it should automatically set up my group. I tried the folllowing but it doesn't work. It is on the solaris OS. HOSTNAME=$(hostname) if ] || ]... (14 Replies)
Discussion started by: Pateltiger
14 Replies

6. Shell Programming and Scripting

How to use newgrp or sg in user mode without password prompt?

Hi, Is it possible to call newgrp or sg from user mode without password prompt in a Linux script? Thank you. hce (2 Replies)
Discussion started by: hce
2 Replies

7. Shell Programming and Scripting

what is the right way to use newgrp in script

my requirement is $ id user o/p for the above command $ uid=1(user) gid=2(x) a user is involved in 3 groups x,y,z whenever the user try to execute a script, script should ask for the group as input from user ,assume the group he wants to change as Y and the rest of the... (3 Replies)
Discussion started by: ram_unx
3 Replies

8. Shell Programming and Scripting

Automating 'newgrp' command - how?

Hi, I have to add the 'newgrp' command to my login (.cshrc) script. The problem is that if I add it, it comes to infinite look, since newgrp opens new shell again and again. How to automate the newgrp when I have to login, and avoid that loop? Currently I'm thinking of a condition that... (2 Replies)
Discussion started by: moshmosh
2 Replies

9. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

10. UNIX for Advanced & Expert Users

newgrp command

I'd like to make an alias of commands which contains the command newgrp. exple: alias my_cmde newgrp toto; my_pg & this line doesn't work. why ? Thanks for your help (2 Replies)
Discussion started by: Nathe
2 Replies
Login or Register to Ask a Question