ksh to bash mode


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh to bash mode
# 1  
Old 10-24-2008
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 loosing all the aliases which were active in my parent (ksh)...
I understand that by typing BASH at the cmd line, I am starting a child process which should atleast inherit the charateristics(aliases etc) of the immediate parent....But in this case, its not happening.
Can somebody explain me this scenario?...and If there is a best(minimal) way to have the similar behavior as the parent, what would that be?...

PS: Please don't advice to DOT the profile once again !

-Anduzzi
# 2  
Old 10-24-2008
And why don't you just change your login shell?

If you cannot change your login shell add the following in your .profile:

Code:
[ -x /path/to/bash ]&&exec /path/to/bash -l


Last edited by radoulov; 10-24-2008 at 01:04 PM..
# 3  
Old 10-24-2008
Thanks for the input.
Could you please eloberate on this command?..I need to know what exactly I
[ -x /path/to/bash ]&&exec /path/to/bash -l
am doing here...

-Anduzzi
# 4  
Old 10-24-2008
-x checks if you have permission to execute the file (the bash shell in this case), if the test returns true, substitutes (the exec builtin) your current shell with bash run as a login shell (the -l switch).
# 5  
Old 10-24-2008
Thx...
Does this substitution pre-vail multiple sessions?....or
when I log out of the current session, the login shell will be back to KSH again?..which means I am dealing with a single session ONLY with out effecting other developers !!!

-Anduzzi
# 6  
Old 10-24-2008
If you put that command in .profile it will affect everyone using that initialization file (the same username). If you put that in .kshrc or whatever file you use for your interactive sessions, it will affect all interactive sessions that use that rc file.
# 7  
Old 10-24-2008
Alright...I see your suggestion here...
But, I don't have any .kshrc(or any kind of such interactive programs) in my HOME which forces me to change the .profile.

Am I missing something?..

-Anduzzi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Fedora

Bash in Emergency Mode

I'm sure this is a really dumb question, but if I use a command in Fedora 23 emergency mode, and that command doesn't exist, I don't come back to the command prompt, but enter what appears to be a text mode. How do I get back to the command line? (2 Replies)
Discussion started by: bangorme
2 Replies

2. UNIX for Dummies Questions & Answers

New user in bash mode

when I created user and use su - username then its prompt come in bash mode # su - uusr -bash-4.1$ What is this bash mode . this also show -bash-4.1$ touch filename touch: cannot touch `filename': Permission denied Please use CODE tags (not ICODE tags) when displaying... (2 Replies)
Discussion started by: kaushik02018
2 Replies

3. Shell Programming and Scripting

tftp batch mode within bash script

Hi, I put the necessary tftp commands into a batch file and I can run tftp by $ tftp < tftpbatchscript in bash command line and then successfully exit. Now, I want to put a line which does the same thing above. However, when I put this line into a bash script, the lines below this line... (1 Reply)
Discussion started by: yildiz.a
1 Replies

4. Shell Programming and Scripting

set ksh script in restricted mode

Hi, I came across a post wherein you can use "set -r"(on bash) to activate restricted mode ( wherein you cant run some commands such as cd etc). Can anyone guide if we have anything similar in ksh ? Thanks (2 Replies)
Discussion started by: Shivdatta
2 Replies

5. 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

6. 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

7. 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

8. UNIX for Dummies Questions & Answers

ksh in vi mode, choose from output

is there a way to choose the complement from the output from the sequense in "ksh -o vi" root# ls testa testb root# cat tes 1) testa 2) testb root# cat tes <-- what to do now? this output looks like a select function, otherwise the numbers wouldn't make sense, is there a chance to use... (2 Replies)
Discussion started by: pressy
2 Replies

9. Shell Programming and Scripting

python vs bash - verbose mode

hey all! i'm looking how to render verbose python scripts. what i'm looking for would be an equivalent to a "bash -xf" in bash script headers.. Any help? (2 Replies)
Discussion started by: penguin-friend
2 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