Operating System - HP-UX
1833783 Members
2272 Online
110063 Solutions
New Discussion

Re: Second file /etc/profile ???

 
tom quach_1
Super Advisor

Second file /etc/profile ???

Hi All,

Is it possible to create a second global profile as /etc/profile2
and have users with certain group go thru
this profile2 and skip the /etc/profile.

Please advice.
Thanks in advance.
Tom
10 REPLIES 10
Devender Khatana
Honored Contributor

Re: Second file /etc/profile ???

Hi,

I do not think it is possible. ANyways what is that which require this?

A variable set in the .profile of the user will override the setting of /etc/profile not requiring this.

HTH,
Devender
Impossible itself mentions "I m possible"
Peter Godron
Honored Contributor

Re: Second file /etc/profile ???

Tom,
the idea of /etc/profile is that is a global profile.
I would suggest you change the /etc/profile to include an if statement and split the executaion path by user group.
That way you still maintain the global profile idea, but can customise for your user group.
Arunvijai_4
Honored Contributor

Re: Second file /etc/profile ???

Hi Tom,

I dont think it is possible to do that. Anyways, you have /etc/profile and $HOME/.profile files, you can do the modification with user's profile which is safer .

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Peter Godron
Honored Contributor

Re: Second file /etc/profile ???

I think Tom wants all users in a specific group to execute /etc/profile2.
Otherwise he has to configure the .profile in each of that groups user directories.
tom quach_1
Super Advisor

Re: Second file /etc/profile ???

Thank you for your quick replies

My purpose is to have different groups connect to different profiles but keep the /etc/profile as is. This is production box and i do not want to mess up this /etc/profile.
please give me advice on how to modify /etc/profile.

at the begining of /etc/profile, i will have if .. else statement.
if the condition met then it would execute the new /etc/profile_new and then execute local user profile.
if not it just continue /etc/profile.

Thanks,
Tom
Senthil Kumar .A_1
Honored Contributor

Re: Second file /etc/profile ???

Hi Tom,

Here is the if statement u are looking for..

first create a file say /etc/special_group

Let this file be filled with the name of the users for whom the /etc/profile2 needs to be executed. One user per line.

Now in /etc/profile include this if statement,

if [ `grep -q "$LOGNAME" /etc/special_group`]
then
. /etc/profile2
fi

The character in front of grep is "back quote" used for command substitution not "single qoute". This character appears before the "1" key.

Contact ,if the test fails.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Senthil Kumar .A_1
Honored Contributor

Re: Second file /etc/profile ???

Hi again,

NOTE:
inside the If statement in the above response there is a space between the "." and "/etc/profile2",

this is important, because. this will make sure that the profile2 is executed in the parent process environment, instead of spawing the child shell(which would be useless in this case).

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
tom quach_1
Super Advisor

Re: Second file /etc/profile ???

Hi Senthil Kumar .A

I do not want to continue execute the /etc/profile after
. /etc/profile2

should i insert a line
break in here

Thanks,
Tom


if [ `grep -q "$LOGNAME" /etc/special_group`]
then
. /etc/profile2

break

fi

Senthil Kumar .A_1
Honored Contributor

Re: Second file /etc/profile ???

Just a sec, I will check my profile file and tell u where exactly to insert, so that it is effective.
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Senthil Kumar .A_1
Honored Contributor

Re: Second file /etc/profile ???

Hi,

Include the if statement at the end of the /etc/profile, thereby it can reinitialize the Variables if it was already initialized by /etc/profile.

Note, before making the change make sure, you make a copy of the actual /etc/profile file somewhere safe,

While testing, include the follwoing command in /etc/profile2

echo "excuting /etc/profile2"

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)