Operating System - HP-UX
1753394 Members
6942 Online
108792 Solutions
New Discussion

Re: How to source in .profile automatically upon login?

 
dictum9
Super Advisor

How to source in .profile automatically upon login?

 

HP-UX 11.31

A user uses /usr/bin/sh and when the user logs in, the $HOME/.profile should be sourced in automatically instead of manually, such as . ./.profile

 

How to automate this process?

I know bash does with .bash_profile but it's not an option at this point.  

7 REPLIES 7
Patrick Wallek
Honored Contributor

Re: How to source in .profile automatically upon login?

If you are using the POSIX shell, /usr/bin/sh, the the ~/.profile file should be sourced automatically when you login.

What are the permissions on the file?  If the user logging in does not have read, and possibly execute, permission on the file then it won't work.  The user logging in should also own the file.

pooderbill
Valued Contributor

Re: How to source in .profile automatically upon login?

Is .profile an ordinary file in the user's $HOME directory (not symlink, not a file from an NFS source)?
Do you see items from /etc profile? Any error messages after /etc/profile has run? You can place an echo line at the start of .profile to see if it is actually being run. 

dictum9
Super Advisor

Re: How to source in .profile automatically upon login?

.profile is set to octal 740 and the ownership is set to user:users

 

 

ranganath ramachandra
Esteemed Contributor

Re: How to source in .profile automatically upon login?

What happens when the user logs in after adding a "set -x" line at the beginning of the ".profile" file ?

 
--
ranga
[i work for hpe]

Accept or Kudo

dictum9
Super Advisor

Re: How to source in .profile automatically upon login?

I put the line I wanted to be run in /etc/profile and it sourced  when a user logged in. I don't know why each individual's user .profile does not get sourced at all, I've always had to do it manually, like this.

There are no solutions in this thread other than editing global /etc/profile.

 

. ./.profile

 

 

pooderbill
Valued Contributor

Re: How to source in .profile automatically upon login?

...There are no solutions in this thread...

It is really difficult to help when there are no answers to the questions or suggestions already given.

Can you answer these questions?

Is .profile an ordinary file in the user's $HOME directory (not symlink, not a file from an NFS source)?
(hint: ls -l $HOME/.profile)

Any error messages after /etc/profile has run?

Place an echo line at the start of .profile to see if it is actually being run. 
(hint: echo "just started .profile")

Or even better, debug .profile as suggested above by inserting set -x at the top of .profile

One other thought: Is there something strange at the end of /etc/profile like starting another shell?

It would help to see the results from the questions above.
What you are describing is not normal so resolving the problem will not be a simple solution.

Steven Schweda
Honored Contributor

Re: How to source in .profile automatically upon login?

> I don't know why each individual's user .profile does not get sourced
> at all, I've always had to do it manually, like this.

   I have never seen it fail.

> There are no solutions in this thread other than editing global
> /etc/profile.

   Perhaps that is because, never having seen it themselves, no one can
guess how you managed to obtain this behavior.

> .profile is set to octal 740 and the ownership is set to user:users

   And responses like this don't help.  As usual, showing actual
commands with their actual output can be more helpful than vague
descriptions or interpretations.

   Around here, for example:

rux$ uname -a
HP-UX rux B.11.31 U ia64 1678555272 unlimited-user license

rux$ who am i
sms pts/ta Nov 9 13:22

rux$ grep sms /etc/passwd
sms:x:50:20:Steven M. Schweda:/usr/users/sms:/usr/bin/sh

rux$ echo $HOME
/usr/users/sms

rux$ ls -ld $HOME
drwxr-xr-x 2 sms sys 8192 Nov 9 13:22 /usr/users/sms

rux$ pwd
/usr/users/sms

rux$ ls -lA .profile
-rw-r--r-- 1 sms users 2391 Nov 9 13:22 .profile

   In this case, I own my home directory and my ".profile", I can read
both of them, and I'm the only one with write permission on both of
them.  Some of those things may be significant.

   And, from a convenient Mac:

pro3$ rsh rux
Password:
Last successful login: Thu Nov 10 16:42:35 CST 2016
pro3.antinode.info
Please wait...checking for disk quotas
[.profile]

Value of TERM has been set to "xterm".
rux$

   That "[.profile]" line comes from a line near the top of that
".profile" file:

echo '[.profile]'


> What you are describing is not normal so resolving the problem will
> not be a simple solution.

   The solution might be simple, but it's not immediately obvious, so
answering questions accurately and precisely will probably be even more
important than usual.  You might try that.