How to execute a ".profile" depending on the server from where the user is connected.


 
Thread Tools Search this Thread
Operating Systems Solaris How to execute a ".profile" depending on the server from where the user is connected.
# 1  
Old 08-10-2012
How to execute a ".profile" depending on the server from where the user is connected.

Hello,

I have two Solaris servers on a cluster. I have created the same user "X"on the two nodes (same UID and same GID). The file ".profile" of this user "X" is located in a filesystem that is seen by the two nodes.

Each server should have a ".profile" of this user different of the other server.

I want to create a ".profile" that detect from what server the user "X" isconnected and then execute the right ".profile".

Any ideas ?

thanks
# 2  
Old 08-10-2012
What about this. Let's assume the two hostnames are server1 and server2. Then write the .profile as
Code:
. ~/.profile.$(hostname)

and the two files .profile.server1 and .profile.server2 are the actual profiles.

---------- Post updated at 11:48 ---------- Previous update was at 11:47 ----------

... and if there are identical parts in both profiles, then just put these parts into .profile itself.
# 3  
Old 08-10-2012
Thanks for your answer. Just one question: when the user connect to the server, it's the file ".profile" that will be executed and not ".profile.server1" or ".profile.server2" ?
# 4  
Old 08-10-2012
The login shell "includes" (not executes) the .profile file of the user. This file may include other files with the '.' (dot) command.
# 5  
Old 08-10-2012
But this will execute the two ".profile" files ?
# 6  
Old 08-10-2012
The shell only knows about .profile, everything else is subject to what you write into this file. For example, including another file.
# 7  
Old 08-10-2012
If the user has access to the same $HOME/.profile when logging in on both systems, you can include something like:
Code:
case "$(uname -n)" in
(server1) do stuff you only want when you login on server1 ;;
(server2) do stuff you only want when you login on server2 ;;
esac

in your .profile.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Nim server "Unable to execute remote client commands"

Hello, What is its mean? Could you please help me? Best regards, root@nimserver:/> nimadm -j nimadmvg -c dev4 -s spot1 -l lpp_source1 -d "hdisk7" -Y Initializing the NIM master. Initializing NIM client dev4. 0042-006 c_rsh: (exec_nimsh_cmd) exec_cmd Error 0 poll: setup failure... (2 Replies)
Discussion started by: getrue
2 Replies

2. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

3. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Number of times a user is "connected"?

hi i wish make a shell to look for the number of times a user is connected then makes a "whatch dog" by crontab to handle this i could do it through ps-fedal| grep user_name | wc-l ... etc. but others suggested me another algorithm :mad: and thought to use w, or finger, or who but it have a... (1 Reply)
Discussion started by: edgar287
1 Replies

6. UNIX for Dummies Questions & Answers

return code capturing for all commands connected by "|" ...

Hi, While I am using "|" to join multiple commands, I am not getting the return code when there is error in one of the commnads. Eg: b=`find /path/a*.out | xargs basename` if ; then echo "Error" fi if there is error while finding the file or getting the basename, the $? is... (6 Replies)
Discussion started by: new_learner
6 Replies

7. UNIX for Dummies Questions & Answers

Where can I read about the difference between "..profile" and ".profile"

Hi I know from reading O Riley's Classic Shell Scripting' that the .profile file is " the shells configuration file" but I am unable to find a reference to what "..profile" means. I have searched on the net, Sams Teach Yourself Unix, Unix Visual Quickstart Guide and Linux in a Nutshell. I have... (2 Replies)
Discussion started by: zorrokan
2 Replies

8. Shell Programming and Scripting

communicating wth another user aside from "wall" and "write"

Hi, Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I... (6 Replies)
Discussion started by: Deanne
6 Replies
Login or Register to Ask a Question