If bashrc is for bash what is for ksh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers If bashrc is for bash what is for ksh
# 1  
Old 01-10-2014
Question If bashrc is for bash what is for ksh

I need to set the bash and ksh to my .profile by softlink.

While bashrc works for bash what filename and location do i create for setting ksh shell to my .profile ?

Both bash and ksh are not currently setup.
# 2  
Old 01-10-2014
.profileor.kshrc in which case you will have to inform .profile:
Code:
export ENV=$HOME/.kshrc

But I dont get you here, your set your environmen to the shell you use when you login, and so cant have2 or 3 shells env set at login...
# 3  
Old 01-10-2014
vbe is right AND there is an additional point to it:

~/.profile, ~/.bashrc and ~/.kshrc are executed at different points in time. They cannot and should not be used instead of one another.

~/.profile is executed once per session and is triggered by the login process. Every time you log on to a system, your profile is executed in your login-shell, which is determined by the contents of /etc/passwd:

Code:
root:!:0:0::/:/usr/bin/ksh
daemon:!:1:1::/etc:
bin:!:2:2::/bin:
sys:!:3:3::/usr/sys:
adm:!:4:4::/var/adm:
uucp:!:5:5::/usr/lib/uucp:
nobody:!:4294967294:4294967294::/:
lpd:!:9:4294967294::/:
lp:*:11:11::/var/spool/lp:/bin/false
bakunin:*:1000:1:My Real Name:/home/bakunin:/usr/bin/ksh

You can have another shell started in ~/.profile, but this won't change the fact that first the shell mentioned in /etc/passwd will be executed and the script ~/.profile will be started within it.


kshrc and bashrc

Whenever a shell starts it reads a so-called "rc-file" (resource-file), from which it takes additional configuration(s). This is a quite common behavior of UNIX-programs: mwm has ~/.mwmrc, xinit uses ~/.xinitrc, ftp/rexec share ~/.netrc etc.. The same way ksh uses ~/.kshrc and bash uses ~/.bashrc.

These rc-files are regular scripts, but they are executed in the starting shell and should be used to make all the configurations you want to have. Every time a new shell starts these scripts are executed and will set the shell to a standardized state. This has some implications.

For instance, it looks like a good idea to have something like:

Code:
PATH=$PATH:/some/additional/path

in it, but think it over: every time you start a new shell instance this will be executed, adding another "/some/additional/path" to your path. If you have three or four shell instances open (one in the other) it will get appended every time you open another shell.

As kshrc and bashrc are both scripts and most of the script language in ksh and bash is identical you might succeed in writing a script which is understood in both shells, so you can create a link and use only one for both shells. Chances are you will have problems when it comes to configuration options only one of the two shells support.

Another thing is: ksh (i am not sure about bash, because i rarely use this shell, but i suppose it is the same) can be configured to use anthoer configuration file instead of the standard ~/.kshrc. If a variable "ENV" is set and points to an executable file, this file is used instead of the default ~/.kshrc. This is why it is a good idea to set:

Code:
ENV=~/.kshrc
export ENV

in your ~/.profile.

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing from bash to ksh

Hello, I want to run a script written in ksh but my default shell is bash as root e.g in the script it has #!/bin/ksh i have gone into /etc/passwd to change it from :/bin/bash to /bin/ksh but still giving me an error when running scripts such as ./installer -bash: ./installer: /bin/ksh:... (3 Replies)
Discussion started by: DOkuwa
3 Replies

2. Shell Programming and Scripting

Bash to ksh problem

Hi all Below code works in bash but it is not working in ksh. enddate=`date -d "$enddate + $i day" "+%Y_%m_%d"` Please help me how it works in ksh Thanks (10 Replies)
Discussion started by: pmreddy
10 Replies

3. Shell Programming and Scripting

BASH to KSH

I have a script in KSH and now need to incorporate this into another script which is in BASH. OUr script contains code like below in good number of places. Eg: echo “A B C” | read VAR1 VAR2 VAR3 This works only in ksh and not in BASH. Please let me know 1. Which is the equivalent... (3 Replies)
Discussion started by: cvsanthosh
3 Replies

4. Shell Programming and Scripting

ksh vs bash

what is diff between KSH and Bash can you tell me some commands which run in either of two but not in both. while doing normal shell programming I am unable to find diffrence between two (2 Replies)
Discussion started by: pasricha.kunal
2 Replies

5. UNIX for Dummies Questions & Answers

bash preferred or ksh with bash features

I'm a user on a fairly locked down sys V server. By default, I have ksh set as my default shell. I added to my .profile: bash -o vi so when I login, it goes into bash so I can take advantage of tab completion and use the up key to bring up previous commands. However, whenever I want to exit, I... (2 Replies)
Discussion started by: mrwatkin
2 Replies

6. Solaris

ksh vs bash

Hi, I've a general question regarding shell. I 've seen that every where i worked in production environment people are using ksh .. but i like to use .. bash .. is there any particular reason why hardcore sysadmins use ksh ? (8 Replies)
Discussion started by: fugitive
8 Replies

7. Shell Programming and Scripting

ksh to bash mode

Hi guys... I have a ksh shell by default, so when I login to my unix box, all my .profile statements gets executed(including the aliases). But for some reasons(may be not comfortable using ksh), I would always switch to BASH(in the same session but as a child process) but in the process I am... (16 Replies)
Discussion started by: anduzzi
16 Replies

8. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

9. Shell Programming and Scripting

Need help : KSH>BASH

Hello, I've written a script in KSH, but now it needs to run on a system without KSH, ie sh or bash etc, bash seems best bet, but the simplest of things don't seem to work.. The snippet below is the main issue, basically I'm reading from a dat file and putting fields into arrays.. Dat file... (5 Replies)
Discussion started by: itsupplies
5 Replies

10. Shell Programming and Scripting

Ksh vs Bash

Hi Buddy, Can any one help me to overcome from the below problem? #/usr/bin/ksh typeset -Z dd dd=1 echo $dd =========== out put for the above is 01 same script I'm migrating to bash but typeset -Z option is not found in bash, Pls get me the equivalent option in BASH Thanks in... (1 Reply)
Discussion started by: krishna
1 Replies
Login or Register to Ask a Question