How to set up newgrp on .profile?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to set up newgrp on .profile?
# 1  
Old 04-08-2013
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.

Code:
HOSTNAME=$(hostname)

if [[ "$HOSTNAME" = "tpat1a" ]] || [[ "$HOSTNAME" = "tpat2a" ]]
then
newgrp unixteam
umask 002
fi

Any help will be appreciated.

Thanks
PT

Last edited by fpmurphy; 04-11-2013 at 12:38 AM.. Reason: duplicate message removed
# 2  
Old 04-08-2013
In what way does it not work? Have you tried putting an echo statement in there to see if it's at least trying to run that code?

What is your login shell?
# 3  
Old 04-08-2013
I am working on ksh. When I inserted that script on my .profile and executed it (. ./.profile), it didn't change my group. I am wondering if there is anything wrong on my script or Does this should be different on unix and linux host? Do I need to modify anything to make it work?
# 4  
Old 04-08-2013
Just checking, the group exists right? Can you check the value of hostname? Try running the command in the command line and see if it changes.

--ahamed
# 5  
Old 04-08-2013
Yes, the group exists. I can use this "newgrp <groupname>" from command line. I have to type it all the time everytime I log in. I want to keep it in my .profile so that I don't have to type it again and again. Most of the time I forgot and it messess up everything.
# 6  
Old 04-08-2013
Try executing the .profile with -x option and see if there are any errors. bash -x .profile Also, check if the hostname is correct.

--ahamed
# 7  
Old 04-08-2013
Put an 'echo' statement in your .profile so you can tell if it's actually being run.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

"ksh: XYZ: parameter not set" in .profile

Hi, A very basic query. I am working on two different UNIX servers and I see different behaviours for my user id. This has to be a setting in the .profile, but I can't seem to find where :confused: So, in one server if I type echo $XYZDD (a random variable), I get a blank line with no... (2 Replies)
Discussion started by: ALDonP
2 Replies

3. 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

4. AIX

How to make LOGNAME writeable? It is set as READONLY in .profile

LOGNAME variable is set as READONLY in .profile. I want to make it WRITEABLE so that I can modify the LOGNAME values programatically/throush shell programs. Thanks, Guru (1 Reply)
Discussion started by: gurubbc
1 Replies

5. Solaris

How do i permanently set bash profile??

Hi all, I don't want to enter below command on solaris every time. How do i permanently set this command on Solaris. I know that this operation is a piece of cake on redhat because there is a /etc/rc.local file on it. But Solaris ???? bash-3.00#export PS1="\e (2 Replies)
Discussion started by: getrue
2 Replies

6. UNIX for Dummies Questions & Answers

.profile problem using set -o vi

The “set -o vi” command won't run in the .profile. WHY? This has me puzzled as the problem seems to be too simple, but can't figure it out. Here's the info... Running... Generic sun4u sparc SUNW,Ultra-5_10 K shell Here's the .profile # Copyright (c) 2001 by Sun Microsystems, Inc. # All... (12 Replies)
Discussion started by: jimmyc
12 Replies

7. UNIX for Dummies Questions & Answers

set background/foreground color in .profile

I am using a telnet session (VT100) and need to modify my .profile so that it will set the color of the telnet session. I am not using Xterm (ie: can't use .Xdefaults). I am able to change the colors via menu's but need to preset in .profile. Is this possible??? Can't find anything at all on how... (3 Replies)
Discussion started by: dvella
3 Replies

8. UNIX for Dummies Questions & Answers

ssh2: .profile not set correctly

When logging into solaris box through ssh, my profile does not get set correctly and I'm presented with the default ksh prompt "$". When logging in through telnet, everything is set correctly. Is there a special profile that sshd runs? ssh2: F-Secure SSH 2.4.0 (build 15) on sparc-sun-solaris2.8 (0 Replies)
Discussion started by: dangral
0 Replies

9. UNIX for Dummies Questions & Answers

newgrp in a script

I want to do these commands in a script: if the user name is 'toto' then the user switch to the group toto_group and then 2 others scripts are launched. Unfortunately, after the command 'newgrp' the 2 scripts are not launched correctly. But if I do the same, by hand, one line per one line, it... (11 Replies)
Discussion started by: Nathe
11 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