Operating System - HP-UX
1831554 Members
3838 Online
110025 Solutions
New Discussion

Re: How to override bounce shell with korn shell

 
SOLVED
Go to solution
Hunki
Super Advisor

How to override bounce shell with korn shell

Q)How to override the bourne shell with korn shell.

I did the export SHELL=/bin/ksh in .profile and the echo $SHELL also gives me /bin/ksh but the passwd file has /bin/sh for this user and commands like alias and $PWD do not work for me . How to override the SHELL so that all these commands work through my .profile.
10 REPLIES 10
Heironimus
Honored Contributor

Re: How to override bounce shell with korn shell

You would need to use chsh to change your login shell. Make sure you know what you're doing.
Jeff_Traigle
Honored Contributor

Re: How to override bounce shell with korn shell

If you want to change your shell, you must change it in /etc/passwd. Safest way to do this is run the change shell command, chsh. See the man page for useage.
--
Jeff Traigle
Steven E. Protter
Exalted Contributor

Re: How to override bounce shell with korn shell

Shalom,

Get the sysadmin to change you in /etc/passwd ??

In scripts:

#!/usr/bin/ksh

/bin/sh in HP-UX is the posix shell. It is almost identical to the korn shell.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Laurent Menase
Honored Contributor

Re: How to override bounce shell with korn shell

in .profile:

if [ "$SHELL" = "/bin/sh ]
then
SHELL=/usr/bin/ksh
exec ~/myprofile
fi


and in myprofile
#!/usr/bin/ksh
. ~/.profile
exec /usr/bin/ksh

it should work
B.MariappaN
Advisor

Re: How to override bounce shell with korn shell

use #chsh username shell-path

Regards,
B.MariappaN
A. Clay Stephenson
Acclaimed Contributor

Re: How to override bounce shell with korn shell

What you think is the Bourne shell is, in fact, the POSIX shell and is actually a slightly more enhanced shell than the Korn. Unless you have a compelling reason to change, I would leave the shell as /usr/bin/sh.
If it ain't broke, I can fix that.
Patrick Wallek
Honored Contributor

Re: How to override bounce shell with korn shell

If you are running HP-UX of any recent version, then /usr/bin/sh (/bin/ is a link to /usr/bin/) is ACTUALLY the POSIX shell and NOT the bourne shell.

Anything you are used to using in ksh should work in the POSIX shell.
Hunki
Super Advisor

Re: How to override bounce shell with korn shell

Laurent,

its gives me the following error when running .profile :

syntax error: `end of file' unexpected
spex
Honored Contributor
Solution

Re: How to override bounce shell with korn shell

Hunki,

The first line is missing a quote:
if [ "$SHELL" = "/bin/sh" ]

Notice that this approach doesn't actually change the shell. Rather, it runs ksh as a sub-shell of sh.

The best solution is to change the user's shell in /etc/passwd via 'vipw' or 'chsh /usr/bin/ksh', provided that the user IS NOT ROOT. You must never change root's shell from /sbin/sh, as /usr is not mounted in single-user mode.

PCS
Hunki
Super Advisor

Re: How to override bounce shell with korn shell

Thanks All , Closing thread and giving you the required points.