AlienNation
03-12-2007, 01:21 PM
Hi!
I'm writing a script in which I need to use the command
newgrp <group>
After the newgrp command I need to execute a bunch of other commands and scripts.
However, if I for example use
#!/bin/sh
newgrp <group>
script1.sh
command1
script2.sh
newgrp will create a new shell and the remaining commands will not be run until after the newgrp command returns which is not what I want. I want the commands to be run from within the new shell created by newgrp.
Simply changing my login to use <group> as my primary group is not an option since it's in a corporate environment and I do not have access to do those changes.
I saw an example that looked something like
newgrp group << ENDGRP
script1.sh
command1
script2.sh
ENDGRP
but I couldn't get that working. I don't even fully understand what it's supposed to be doing though I guess it would be some kind of redirection/piping of the commands or something...
Also tried a futile
newgrp <group> script.sh
The newgrp man page doesn't reveal anything regarding this issue and I was unable to find any helpful information on google or elsewhere on this forum.
Anybody got a clue how to do this or is there some other way to change the current primary group?
Thanks
I'm writing a script in which I need to use the command
newgrp <group>
After the newgrp command I need to execute a bunch of other commands and scripts.
However, if I for example use
#!/bin/sh
newgrp <group>
script1.sh
command1
script2.sh
newgrp will create a new shell and the remaining commands will not be run until after the newgrp command returns which is not what I want. I want the commands to be run from within the new shell created by newgrp.
Simply changing my login to use <group> as my primary group is not an option since it's in a corporate environment and I do not have access to do those changes.
I saw an example that looked something like
newgrp group << ENDGRP
script1.sh
command1
script2.sh
ENDGRP
but I couldn't get that working. I don't even fully understand what it's supposed to be doing though I guess it would be some kind of redirection/piping of the commands or something...
Also tried a futile
newgrp <group> script.sh
The newgrp man page doesn't reveal anything regarding this issue and I was unable to find any helpful information on google or elsewhere on this forum.
Anybody got a clue how to do this or is there some other way to change the current primary group?
Thanks