Operating System - HP-UX
1824963 Members
3476 Online
109678 Solutions
New Discussion юеВ

Re: Posix Shell Vs Korn Shell

 
SOLVED
Go to solution
Glynn Aherne_1
Advisor

Posix Shell Vs Korn Shell

Firstly what are the differences between the Posix shell and the Korn Shell.

Secondly, I looking to change the default shell for users logging onto HP-UX 11 system from Posix to Korn.

All our scripts have #!/bin/sh as the first line. If I change the users default shell, will this affect the execution of these scripts?

Thanks,

Glynn.
15 REPLIES 15
Christopher McCray_1
Honored Contributor

Re: Posix Shell Vs Korn Shell

Hello,

An answer to the second question: No, it shouldn't cause a problem; The scripts will merely run in a Bourne subshell.

Hope this helps

Chris
It wasn't me!!!!
Ian Lochray
Respected Contributor

Re: Posix Shell Vs Korn Shell

/bin/sh is the Posix shell. The Bourne shell is in /usr/old/bin/sh.
Ken Hubnik_2
Honored Contributor

Re: Posix Shell Vs Korn Shell

The default shell is the bourne shell. I think that all functions of the ksh shell were built into the bourne shell.
Pete Randall
Outstanding Contributor

Re: Posix Shell Vs Korn Shell

Glynn,

I'm quoting from a HP Posix Shell Programming course book:

. The POSIX shell is very similar to the Korn shell

. The POSIX shell is fully compliant with the IEEE P1003.2 recommendations

. These POSIX recommendations are adopted as the industry standard.

. The POSIX shell is essentially compatible with the HP-UX Korn shell


So, the differences then are slight at best, and the POSIX shell is more standards compliant and accepted - I'd go with POSIX rather than Korn.

Pete

Pete
Ken Hubnik_2
Honored Contributor

Re: Posix Shell Vs Korn Shell

Sorry I meant to say that the default shell is the posix shell and all the ksh functions are built into the posix shell.
Jean-Louis Phelix
Honored Contributor
Solution

Re: Posix Shell Vs Korn Shell

Hi,

A - Posix Shell and Korn Shell are very similar. You have to use it in depth to see differences ...

B - The first line of a script beginning with #!xxx only indicates the interpretor to use. So it could contain anything and it absolutly not related to your logging shell, but I just wanted to add that /bin/sh shouldn't be used anymore because it's a transition link maintained only for compatibility with old releases. You should now rather use #!/usr/bin/sh

Regards,

jean-Louis.
It works for me (┬й Bill McNAMARA ...)
Jeff Schussele
Honored Contributor

Re: Posix Shell Vs Korn Shell

Hi Glynn,

All functions of the korn shell are contained in the Posix shell and more.
So you could consider ksh to be a subset of sh OR that sh is a superset of ksh.
I prefer the Posix to the korn.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Darrell Allen
Honored Contributor

Re: Posix Shell Vs Korn Shell

Hi Glynn,

Don't change root's shell. It needs to be /sbin/sh (note that's /sbin/sh, not /bin/sh). You will be likely to find you can't boot your system if you change it.

If you have #!/bin/sh as the first line in your script, that's the shell (posix) that will be used. It won't matter what shell is specified for the user in /etc/passwd.

Using ksh instead of posix is okay. You lose some functionality that is added in the posix shell. If you use ksh on other systems, you may be more comfortable doing so on HPUX also (though whatever you do in ksh can be done in posix). Also, if you always write your scripts in ksh, they will be more easily portable to other platforms.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Chia-Wei
Advisor

Re: Posix Shell Vs Korn Shell

- Posix Shell is supposed to obsolete Bourne Shell
- Is the default shell for HPUX-10.20 and above
- Having almost similar features as the Korn Shell
Bill Hassell
Honored Contributor

Re: Posix Shell Vs Korn Shell

The POSIX standard applies to a number of shells including Korn, POSIX and bash. HP's POSIX shell is generally a superset of the Korn shell. For example, ulimit -a exists in the HP POSIX shell but there are no options for Korn shell. The POSIX shell has been standard on HP-UX since version 10.00 and 10.01.

Generally, there is more functionality in /usr/bin/sh than found in ksh. To see the exact difference, look at the Release Notes found in /usr/share/doc for the details. The Bourne is virtually unknown (and unused) in HP-UX because it is located in /usr/old/bin/sh. As mentioned, root's shell must be /sbin/sh in order to function in single user mode. Do not change root's shell to anything in /usr as single user mode will fail.

As an additional note: there is no such directory /bin. It has not existed for more than 8 years as it was obsoleted by the SysV.4 filesystem standard. Other flavors of Unix such as Solaris have also migrated out of /bin. To provide backward compatibility, /bin is actually a symbolic link (called a transition link in HP-UX). These links are simply crutches to keep things running until all your tools have been migrated. tlinstall and tlremove will create and remove these links. NOTE: there is no guarentee that these old links will exist in future releases.


Bill Hassell, sysadmin
Greg Pierro
Frequent Advisor

Re: Posix Shell Vs Korn Shell

I know there were lots of replies thus far, but i don't think anyone told you how to change the path of default shell in /etc/passwd. Make sure you always make a copy first. Edit this file with vi or another text editor and change the default shell entry, which is the last field in each record(fields are delimited with colons). You can create a template using SAM for creating users with the same settings.
Jeff Schussele
Honored Contributor

Re: Posix Shell Vs Korn Shell

Slight correction Greg - although one *can* use vi or ed to edit the passwd, it's not recommended.
One should use the vipw command as it will lock the file during edit & post-process it for any changes occuring from another source while being "manually" edited.
It has the further benefit of NOT allowing you to screw up root's entry such that the system would be unbootable.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Mark Ellzey
Valued Contributor

Re: Posix Shell Vs Korn Shell

In regards to Greg's comment about editing the /etc/passwd file, you can use 'vipw' to edit this file. It's much safer that using just 'vi', as it automatically makes a backup copy of /etc/passwd. If you mess up, vipw tell you and restores the backup copy to the original.

Just my 2cents,
Mark
John Palmer
Honored Contributor

Re: Posix Shell Vs Korn Shell

I agree with vipw but in this case, it's simpler to use the 'chsh' command (or 'passwd -e' which is the same thing).

Regards,
John
Charles Stepp_2
New Member

Re: Posix Shell Vs Korn Shell

When using the posix shell, set HISTFILE and HISTSIZE to ensure that you get normal command line editing functionality.
KISS