UNIX Korn Shell to Linux Bash

Migrating Unix batch jobs (Korn Shell) running in HP-UX server to Linux environment.

Hi All

Please help me to understand the easiest way to migrate Kernel Shell scripts to Linux Bash. Also let me know

  1. Any automated scripts or tools available for this.
  2. Challenges and issues (performance, code change etc.)

Please help with your valuable suggestions.

I would assume, althought not completely sure, that bash is compatible with ksh ( only in this direction, not the other way ).

What will be most likely the problem is the usage of external programs. Since HP-UX is a lot different to the linux environment, there could be a lot of change required, especially these kinds:

  • Some path names are different, hardcoded path names for programs will probably have to be changed
  • External commands have to partially be changed
  • invocation of commands with their options and switches are different and have to be adapted

The question to me is, if this is a onetime process or an extension, so that the scripts will run on both platforms in future. For the latter more work is required, to implement some kind of portability layer into all scripts.

Regarding automation, there is nothing I know of. I doubt that there is much regarding the fact that the issue is not to convert ksh syntax but a lot of external program calls, which is no question of converting one defined set of programming language syntax into another(like converting a perl script into c-code, which is possible and where converters exist), but a lot of arbitrary, non-standardized, redundant, ad-hoc code.

See also:
Bash / ksh - Portability Issues

1 Like

There are a few incompatibilities between ksh and bash that might need closer examination, like floating arithmetics, or array assignments, to name some of them.

An option that may reduce porting work is to use ksh on linux.

My system (Linux: Debian 9 - Stretch) shows two available ksh packages here:

  • ksh - Real, AT&T version of the Korn shell
  • mksh - MirBSD Korn Shell

I'm not sure if on of these versions is really compatible with the HP-UX Version of ksh. But since ksh is open source since 2000 I would assume that this issue is safe.

difference between ksh, bash and other shells

The "mksh" is a freeware project which has more in common with bash than ksh but is compatible with neither one. My suggestion is: hands off! The other is a correct and specification-conforming ksh93, in version "u+" or thereabouts. You should use this at any rate.

There are also the sources for the Korn shell, which can be downloaded at Github (GitHub - att/ksh: KornShell Command and Programming Language), since AT&T discontinued to host it. This will guarantee you the latest version but you will have to compile it on your own. I suggest to use the Debian package if you use a Debian-based system. Similar packages with the compiled binaries can be downloaded from RedHat (for RedHat-based systems), etc..

I hope this helps.

bakunin

Thank You all for your quick responses.

as of now we have around 5K batch jobs written using Korn Shell hosted in HP UX server.
we are planning to migrate all Korn Shell batch jobs to Linux Server (RedHat).

Will definitely verify the option shared by Stomp - using KSH in Linux

if as per our requirement, need to migrate all scripts to Linux bash...
Please let me know if any more additional inputs on this.