- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: login script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 07:54 AM
01-29-2003 07:54 AM
The dba's on my systems want to run a different .profile for each system they log on to. We use NIS+ so I can only define one home directory (/home/dba). I renamed the .profile in /u01/dba on node 1 to node1.profile, and the .profile in /u02/dba on node 2 to node2.profile. Then in the .profile in /home/dba I have a case statement.
HOST=`hostname`
case $HOST in
node1)
sh /u01/dba/node1.profile
cd /u01/dba
;;
node2)
sh /u02/dba/node2.profile
cd /u02/dba
;;
esac
The profile scripts have a lot of export commands to set up their environment, but when I run it, none of the exported variables are set.
Why not? What am I doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:01 AM - last edited on 06-29-2021 05:10 AM by Ramya_Heera
01-29-2003 08:01 AM - last edited on 06-29-2021 05:10 AM by Ramya_Heera
SolutionYour spawning a child shell, where the all the env scripts are getting run, but it then exits back to your parent shell, and you lose them all... This should work:
HOST=`hostname`
case $HOST in
node1)
. /u01/dba/node1.profile
cd /u01/dba
;;
node2)
. /u02/dba/node2.profile
cd /u02/dba
;;
esac
The '.' tells the shell to run the commands in the file in the current shell rather than spawning a child process.
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:03 AM
01-29-2003 08:03 AM
Re: login script help
When you run a 'sh', it spawns a shell which loads up the profile, then closed the shell and carries on.
Try replacing 'sh' with '.' in the conditionals and see what happens.
eg .
HOST=`hostname`
case $HOST in
node1)
. /u01/dba/node1.profile
cd /u01/dba
;;
node2)
. /u02/dba/node2.profile
cd /u02/dba
;;
esac
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:05 AM
01-29-2003 08:05 AM