1834461 Members
3009 Online
110067 Solutions
New Discussion

Korn shell

 
SOLVED
Go to solution
Rene_17
Regular Advisor

Korn shell

The profile in /etc don??t work ?
I wanted to change the korn shell prompt but nothing happens when i changed the variable ps1 in the file /etc/profile !
25 REPLIES 25
Pete Randall
Outstanding Contributor
Solution

Re: Korn shell

Are you trying to change the prompt for everyone? For an individual user, just change their ~/.profile.

If you're running CDE, this is what we do to force the sourcing of profiles: in ~/.dtprofile:
DTSOURCEPROFILE=true
. /etc/profile;
. $HOME/.profile;


Pete


Pete
RAC_1
Honored Contributor

Re: Korn shell

The execution sequence is /etc/profile and then .profile of the user.

Check permissions on /etc/profile. ownership should be bin:bin with read access to all.

Put PS1='You stuff Here' and it will work.

/etc/profile is for ksh, sh
for csh /etc/csh.login is executed.
There is no substitute to HARDWORK
Stefan Farrelly
Honored Contributor

Re: Korn shell

works when I change it in my /etc/profile, eg;

PS1='boo> '

But it may be overridden by a users .profile in their home directory as /etc/profile is run before $HOME/.profile - so normally PS1 is set in $HOME/.profile
Im from Palmerston North, New Zealand, but somehow ended up in London...
Mark Grant
Honored Contributor

Re: Korn shell

The profile in /etc certainly should work!

Are you should you are changing "PS1" and not "ps1".

Also, you need to make sure you export it. As an example, try

export PS1="[ $(whoami)@$(hostname) \$PWD ] \$SIGN "
Never preceed any demonstration with anything more predictive than "watch this"
Umapathy S
Honored Contributor

Re: Korn shell

Rene,
Its a normal practice to set PS1 in users profile.
If you are connecting through an X-emulator uncomment DTSOURCEPROFILE at the end of the .dtprofile.

can you post your PS1?
HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Bhuvaneswari Selvaraj
Valued Contributor

Re: Korn shell

1) Did you execute the .profile by logging out and loggin in again.
2) Try giving . ./.profile in the /etc dir
cd /etc
dot space dot/dot profie
are you seeing any error message there?
Rene_17
Regular Advisor

Re: Korn shell

# Shell Prompt:

HOST=$(uname -n)
export HOST
PS1='$HOST:$PWD $ '

These are the entries in /etc/profile !
I want to change the prompt for everyone, so I added it in /etc/profile !

Mark Grant
Honored Contributor

Re: Korn shell

You haven' exported PS1. You need to export that too.
Never preceed any demonstration with anything more predictive than "watch this"
Rene_17
Regular Advisor

Re: Korn shell

that??s it !!!
Umapathy S
Honored Contributor

Re: Korn shell

Rene,
It should work. It works for me. Mark has got it. Did you export PS1?

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Rene_17
Regular Advisor

Re: Korn shell

that??s it !!!
Error myself !
Rene_17
Regular Advisor

Re: Korn shell

too fast: it did??n work !
I added the export ps1, but nothing happened !
Mark Grant
Honored Contributor

Re: Korn shell

Could you confirm you are doing

export PS1

not

export ps1
Never preceed any demonstration with anything more predictive than "watch this"
Rene_17
Regular Advisor

Re: Korn shell

i had entered . ./profile and then the startup script (etc/profile) works !
Mark Grant
Honored Contributor

Re: Korn shell

Entering . ./profile shouldn't make any difference unless you have a really weird .profile.

Could you just confirm that with your exported PS1 in /etc/profile and after logging out and logging in again, it still doesn't work
Never preceed any demonstration with anything more predictive than "watch this"
Rene_17
Regular Advisor

Re: Korn shell

the script is not invoked at shell startup !
When I execute the script /etc/profile manually the last line entry is "logout" ?
I don??t know why ?
Rene_17
Regular Advisor

Re: Korn shell

the script is not invoked at shell startup !
When I execute the script /etc/profile manually the last line entry is "logout" ?
I don??t know why ?
Mark Grant
Honored Contributor

Re: Korn shell

If you are using X to log in, then /etc/profile will not be executed and you should see the related answers above.

If you do "su" then it also will not be run (you need to do su -). Having "logout" as the last line of /etc/profile is weird but not completely idiotic if, for example, you want all your users to run a specific application and then logout when they have finished (you'd need to stop root having the same problem though of course).

I think you are going to have to explain a little more about how you are logging in and perhaps post your
/etc/profile and .profile files.
Never preceed any demonstration with anything more predictive than "watch this"
Rene_17
Regular Advisor

Re: Korn shell

I take exceed to log in to the X window system ! Then I start the shell with the X window toolbar (terminal).
Mark Grant
Honored Contributor

Re: Korn shell

Exceed will not source /etc/profile or .profile. You willl nedd to edit .dtprofile. Have a look at S Umpathy's post above!! This will make Exceed surce the two files.

Alternatively, just to check everything is OK, run
"xterm -ls" to get a log in shell that does source the two files, or even simpler, just run su - yourlogin. But, you will need to edit .dtprofile
Never preceed any demonstration with anything more predictive than "watch this"
Pete Randall
Outstanding Contributor

Re: Korn shell

Rene,

I'll repeat:

If you're running CDE (which you appear to be doing), this is what we do to force the sourcing of profiles: place the following in ~/.dtprofile:
DTSOURCEPROFILE=true
. /etc/profile;
. $HOME/.profile;


Pete


Pete
Rene_17
Regular Advisor

Re: Korn shell

It??s very interresting, because I add the two scripts to .dtprofile adn after that I couldn??t log in to the system.
I have said before that the last word of the script is "logout" !

The scripts works now, but now I have the loout problem !
Pete Randall
Outstanding Contributor

Re: Korn shell

Rene,

So the last line in /etc/profile is "logout"? Maybe you could post (or attach) your /etc/profile, or explaing how you're expecting for this to work? With the "logout" line, I would expect that users would be automatically launching an application (what application?) at login time and logging directly out when they exit that application.

Can you supply more details?


Pete



Pete
Rene_17
Regular Advisor

Re: Korn shell

The scripts works now !
Thanks !!!!!!!!!!!!!!!!

The logout was invoked by the script .profile
see: set -u
trap echo 'logout root'