Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I have a small question about the ksh. My default shell is configured to sh by the administrator. But I prefer to use ksh. So I add the following ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3

    Unhappy how to let ksh run a script without existing itself?

    Hi,

    I have a small question about the ksh. My default shell is configured to sh by the administrator. But I prefer to use ksh. So I add the following lines into my .profile (which will be ran automatically by sh).

    set -o vi
    ksh

    But unluckliy the sh doesn't recognize "set -o vi". And if I remove the line, my ksh won't have the related functionality. I also tried to find a way to let the ksh run another script, but it doesn't work. When the script is finished, ksh will exit.

    Any ideas?

    Thanks,
    Daniel

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by danielnpu View Post
    Hi,

    I have a small question about the ksh. My default shell is configured to sh by the administrator. But I prefer to use ksh. So I add the following lines into my .profile (which will be ran automatically by sh).

    set -o vi
    ksh

    But unluckliy the sh doesn't recognize "set -o vi". And if I remove the line, my ksh won't have the related functionality. I also tried to find a way to let the ksh run another script, but it doesn't work. When the script is finished, ksh will exit.

    Any ideas?

    Thanks,
    Daniel
    I can't help directly because I don't know anything about ksh. But I suggest reading the ksh man page to know what the ksh rc files are, and/or how would you go about specifying the rc file on command line.

    All the commands that must take effect under ksh should be on the ksh rc files, and not in ~/.profile, which is a bash init file. Once you launch ksh from the bash init file, then the ksh rc files should be read.

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3
    Thank you so much. I've found out how to figure this out.

    The solution is simply like this:

    In my .profile which is executed by sh,

    export ENV
    ENV="$HOME/.env"
    ksh

    Then in file $HOME/.env,

    set -o vi

    And that's all. It appears $ENV is automatically executed when ksh is invoked.

    Thanks a lot for your help.

    Regards,
    Daniel

  4. #4
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Can't you use chsh to change your login shell?

    $ chsh
    Changing shell for <user>.
    Password:
    New shell [/bin/bash]: /bin/ksh

  5. #5
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3
    Thank you. It works! I've changed my shell to ksh with chsh.

    I thought only administrator can change my login shell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...