korn shell - not able to see

[root@myserver~]# /bin/ksh
# echo $SHELL

I wonder why ksh is not showing up when i did ksh or /bin/ksh?

I am used with bash, specific app uses ksh so i had to switch.
ittechlabLinux SupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
may be someone made a symlink to be able to run ksh scripts?
Please show the output of the next commands for verification:

ls -li /bin/ksh
ls -li /bin/bash

Open in new window

ittechlabLinux SupportAuthor Commented:
[root@server~]# ls -li /bin/ksh
204546 lrwxrwxrwx 1 root root 21 jan 20 2014 /bin/ksh -> /etc/alternatives/ksh
ittechlabLinux SupportAuthor Commented:
[root@server~]# ls -li /bin/bash
204734 -rwxr-xr-x 1 root root 736348 Sep 25  2014 /bin/bash
Maximize Customer Retention with Superior Service

The IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more to help build customer satisfaction and retention.

nociSoftware EngineerCommented:
right ksh point to /etc/alternatives/ksh so no to check that...

ls -li  /etc/alternatives/ksh

Open in new window

If this again shows a symlink the use ls -li on that as well
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Rarely, if ever, is a real ksh available... unless you manually install it, via your package manger or from source.

Mention OS you're running.

Also, how you ended up with /bin/ksh pointing to /bin/bash, if you know... as, this symlink likely should be released, as there are major differences.

Specifically, you can't expect bash to correctly execute ksh code.

While, ksh will usually correctly execute bash code.
Duncan RoeSoftware DeveloperCommented:
To save repeated ls commands, try readlink -f /bin/ksh. But I think you'll find it's a real ksh.
ksh is standard on my system (Slackware) and in my FC28 (Red Hat) VM I fetched ksh by yum install. In both cases, I found that I could invoke ksh but $SHELL remained unchanged.
The man page for ksh says
The shell gives default values to PATH, PS1, PS2, PS3,  PS4,  MAILCHECK, FCEDIT,  TMOUT  and IFS, while HOME, SHELL, ENV, and MAIL are not set at all by the shell (although HOME is set by login(1)). On some systems MAIL and SHELL are also set by login(1).
Here's how you can be sure you are not running bash: enter shopt. This is a bash built-in command (short for shell options). Under ksh you will get
ksh: shopt: not found [No such file or directory]
ittechlabLinux SupportAuthor Commented:
there is ksh is  available on this server as there is another userd id able to use ksh. not sure why I am not able to use as root account or my account?
Duncan RoeSoftware DeveloperCommented:
root is able to use ksh. You are using it. ksh does not change SHELL - that is not the way to test what shell you are running. SHELL only says what is your default shell (from /etc/profile).
Try issuing shopt after you have issued /bin/ksh. If that fails, you are not running bash any more.
Also try issuing ps. Expect to see something like
  PID TTY          TIME CMD
12533 pts/14   00:00:00 bash
13271 pts/14   00:00:00 ksh
13272 pts/14   00:00:00 ps

Open in new window

Hi David.

Here are some comments on some of your comments:

> "Also, how you ended up with /bin/ksh pointing to /bin/bash, if you know... as, this symlink likely should be released, as there are major differences."
Please quote the text which lead you to believe ittechlab's /bin/ksh is pointing to /bin/bash.

> "Specifically, you can't expect bash to correctly execute ksh code.
> While, ksh will usually correctly execute bash code."

I thought the reverse was true, and just did a quick search and found this which seems to support my understanding:
While I doubt all ksh scripts will run under bash, some relevant quotes from that page are:
 "A syntax in the KSH shell can run in a Bash shell without encountering errors or problems."
 "Bash also acts as an extension of the Korn shell, since it incorporates the features of the latter, with some added features."
Can you link to anything which supports your opposing understanding?
nociSoftware EngineerCommented:
The family tree is bsh -> ksh (improvement on bsh).   and in then  bsh -> bash (also improvement on bsh)
bash is based on free sources whereas ksh was built initialy on restrictive copyrighted (until 2005) sources.
That why bash gained traction in Linux and ksh more in unix environments.

bash (Bourne Again Shell)  and ksh (Korn Shell) both stem from bsh (Bourne Shell).
bash also took some ideas from ksh expanded on them.
As such lots of ksh script run under bash but not the other way around.

That's also why the alternatives package can use a symlink from ksh -> bash to run scripts.. (most of the times).
Duncan RoeSoftware DeveloperCommented:
@noci I never heard of the Bourne shell being called bsh - only sh ?
Duncan RoeSoftware DeveloperCommented:
Also bash got some ideas from csh (C shell) - at least history editing IIRC
nociSoftware EngineerCommented:
History recall was also in ksh, but it needed some special setup due to keyboard issues.  (keystroke editting, not the ! edditing).

bsh is the name used by the package managers.  
and yes it used to be /bin/sh..., but that being a generic name meant that most shells setup a symlink to themselves  names /bin/sh.
Duncan RoeSoftware DeveloperCommented:
Back to the original question: the SHELL environment variable is not there to say which shell is running currently: it's there to tell programs that issue shell commands which shell they should use to do so. No surprise when SHELL does not change on invoking ksh therefore.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.