1828208 Members
2057 Online
109975 Solutions
New Discussion

Re: problem with kshrc

 
SOLVED
Go to solution
Binu_5
Regular Advisor

problem with kshrc

Hi ALL

Iam facing a problem with .kshrc

I have a NIS setup here and there are
hpux and linux sytems in the setup

The problem is the the ailases I have mentioned in .kshrc file will be executed in hpux but not in redhat linux ...


Can anybody throw some light init this
This .kshrc file is in the /home/.profile


Thanks
Binu
7 REPLIES 7
Stuart Browne
Honored Contributor

Re: problem with kshrc

Show us the how the '.profile' calls the '.kshrc' please.

And the dumb question, the user you are logging in as has '/bin/ksh' as it's shell, yes?
One long-haired git at your service...
Binu_5
Regular Advisor

Re: problem with kshrc

Hi

The login looks like this

maheshag:u2QnKE1LLp7k2:392:20:Mahesha Guttahali(Latha's team member):/home/maheshag:/sbin/sh

in Hpux
r-xr-xr-x 1 bin bin 401408 Apr 14 2002 sh
ps give the out put

; ps
PID TTY TIME COMMAND
14318 pts/23 0:00 sh
14348 pts/23 0:00 ps
14094 pts/23 0:00 ksh

in Linux

lrwxrwxrwx 1 root root 12 Feb 17 11:00 sh -> /usr/bin/ksh


Thanks
Binu



Stuart Browne
Honored Contributor

Re: problem with kshrc

Oh boy.. Bad..

Lets start with this.

NEVER LINK 'sh' TO ANYTHING OTHER THAN 'bash' ON A Linux BOX!

If you want a user to use 'ksh' as their login shell, then make the user's shell 'ksh'!

Quite a number of scripts written on a Linux box are written expecting bash functionality! 'ksh' doesn't work in the same manner as 'bash', so some unexpected things WILL happen.

Now, all that said. On a RH box by default, a '~/.kshrc' won't be called.

So this goes back to my previous question, how are you calling your '.kshrc' from your '.profile'?
One long-haired git at your service...
Binu_5
Regular Advisor

Re: problem with kshrc

Hi Stuart

Though my shell is sh ..I dont have any clue from where this .kshrc is been taken
It was a working setup in Hp ux and I never bothered ..
I have checked my .profile and nothing much


Can you pleae let me know where to check

Thanks
Binu
Stuart Browne
Honored Contributor
Solution

Re: problem with kshrc

'pdksh' (which is the default KSH package on a RedHat box) won't call a '~/.kshrc' on it's own.

In the user's profile (or possibly the '/etc/profile'), a section that says something like this is required:

if [ "$SHELL" = "/bin/ksh" ]
then
[ -f "~/.kshrc" ] && . ~/.kshrc
fi

This will execute a '~/.kshrc' if it exists, and the shell is 'ksh'. Using the '.' method of execution means that any environment changes which occur in the '.kshrc' is within the shell's scope, and will stay there.
One long-haired git at your service...
Binu_5
Regular Advisor

Re: problem with kshrc

Hi Stuart

I have copied .kshrc to bashrc and set the
enviromnet in the .profile and it seems to be working

export ENV=$HOME/.bashrc

Thanks for making me think

Thanks
Binu
Binu_5
Regular Advisor

Re: problem with kshrc

Hi Stuart

I have copied .kshrc to bashrc and set the
enviromnet in the .profile and it seems to be working

export ENV=$HOME/.bashrc

Thanks for making me think

Thanks
Binu