Converting from MKS Korn Shell to Linux
am 26.09.2007 20:29:51 von Andra
I have recently switched from Windows to Linux on my work computer.
All of our install scripts are MKS toolkit korn shell scripts. These
scripts work fine on the Windows machine using the toolkit but as soon
as I try to run them on Linux, I am getting syntax errors.
Are there differences between the MKS korn shell and the basic korn
shell and if so, can anyone point me to documentation that lists the
changes I would need to make to be able to run these scripts in Linux.
Thank you in advance.
Re: Converting from MKS Korn Shell to Linux
am 26.09.2007 20:59:07 von Janis Papanagnou
Andra wrote:
> I have recently switched from Windows to Linux on my work computer.
> All of our install scripts are MKS toolkit korn shell scripts. These
> scripts work fine on the Windows machine using the toolkit but as soon
> as I try to run them on Linux, I am getting syntax errors.
>
> Are there differences between the MKS korn shell and the basic korn
> shell and if so, can anyone point me to documentation that lists the
> changes I would need to make to be able to run these scripts in Linux.
>
> Thank you in advance.
>
On Linux you usually find just a PDksh (named ksh). Instead of fiddling
with the differences I'd suggest to download the AT&T ksh (version 93s+
compared to MKS ksh based on a version from 88) from www.kornshell.com
and use that one. I would expect the least migration problems.
You may also use zsh (which I've heard to have a ksh compatibility mode)
but since I haven't tried that mode I'll abstain from a recommendation.
Janis
Re: Converting from MKS Korn Shell to Linux
am 27.09.2007 00:53:50 von brian_hiles
Andra wrote:
> I have recently switched from Windows to Linux on my work computer.
> All of our install scripts are MKS toolkit korn shell scripts. These
> scripts work fine on the Windows machine using the toolkit but as soon
> as I try to run them on Linux, I am getting syntax errors.
> Are there differences between the MKS korn shell and the basic korn
> shell and if so, can anyone point me to documentation that lists the
> changes I would need to make to be able to run these scripts in Linux.
> Thank you in advance.
There are what I can determine are three forks to your
particular situation: utilize a portability library,
duplicate your runtime environment (find a shell that at
least understands some or all MKS-like constructs),
and/or porting (rewrite the code).
I am assuming you are _not_ talking about a portability
library (e.g. PUSE, Typhoon, Bruce Blinn's code, ...)
insofar as unless one specifically address MKS to Linux,
will be of dubious applicability, and I don't know of one.
As far as the second option, I am in agreement with the
recommendation by Janis. ksh93 is an excellent shell -- my
favorite -- that is freely available in binary and source
forms for many host systems, including the PC (under U/WIN).
If you are not an advanced shell scripter, or are charged with
porting code that you didn't write, even using automated ported
tools can be problematic. It is the next revision of the ksh88
that MKS tries to emulate. See "Question 5) True Story?" at:
http://slashdot.org/articles/01/02/06/2030205.shtml ;)
Investigate the "typeset -H" option in ksh88 and ksh93,
providing UNIX to host-name file mapping to/from non-native
filesystems.
However, if true porting is desired (and BTW, there are
potentially non-portable constructs in MKS shell that will
need to be custom hand-coded to _any_ shell that you will
choose to use), there are a couple of options, most of them
not tested by me. They talk of Solaris and AIX, but the
concepts should be universal to any host OS, and perhaps
even some of the applications may be useful.
First, the whitepapers and engineering notes:
"MKS Toolkit Product Overview and Solutions Guide":
http://www.mkssoftware.com/docs/sg/#uwpg
^ find: "Scripting and Automation", "MKS Toolkit Configuration
Files", "UNIX to Windows Porting Guide"
"Porting Shell Scripts",,http://www.microsoft.com/technet/
interopmigration/unix/sfu/pshscrpt.mspx#EIC
"Interix Technical Note -- Porting Shell Scripts"
http://www.microsoft.com/technet/interopmigration/unix/sfu/p shscrpt.mspx
"Portable Shell Programming":
http://www.gnu.org/software/autoconf/manual/autoconf-2.57/ht ml_node/autoconf_114.html#SEC114
http://www.gnu.org/software/autoconf/manual/autoconf-2.57/ht ml_node/autoconf_79.html#SEC79
"What to watch out for when writing portable shell scripts":
http://www.linux.com/articles/34658
"Portable Shell Programming":
http://www.in-ulm.de/~mascheck/various/portability/
"lintsh"
http://code.dogmap.org/lintsh/
And a script:
"shell-test.sh": test shell features for Debian/POSIX compatible
http://www.netfort.gr.jp/~dancer/software/downloads/list.cgi #shell-test
Here are three professional quality application suites of
possible applicability:
"scriptran": Bourne shell script analysis tool, to port Solaris .SH to
RedHat Linux: component-of LinCAT
http://soldc.sun.com/tools/linux/L3.html
http://developers.sun.com/solaris/downloads/lincat/lincat_3. html
http://developers.sun.com/solaris/downloads/lincat/index.htm l
"shanalyze": Solaris to Linux migration tools: component-of Solaris-
Linux Porting Kit (SLPK)
http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailP age_IDX/1,1703,6731,00.html
http://h21007.www2.hp.com/dspp/files/unprotected/slpk/slpkpr esentation.pdf
http://h21007.www2.hp.com/dspp/files/unprotected/slpk/slpkfa q.pdf #
SLPK FAQ
"Port your Solaris application to Linux on POWER": "Linux on Power
Architecture Toolkit" ...
http://www-03.ibm.com/servers/enable/site/linux/landing/port _solaris.html?TACT=105AGX32&S_CMP=SOLLX&ca=dos-migratelx
=Brian
Re: Converting from MKS Korn Shell to Linux
am 27.09.2007 01:17:01 von Ron Hardin
The shell might not be happy with lines ending with \015\012 that
windows is likely to produce.
Recent versions of Cygwin (want to go back to XP? this gives you
a nice Unix-like environment under XP) upgraded to reject \015\012
and so I use an old version. But perhaps it means that linux is the
same.
--
rhhardin@mindspring.com
On the internet, nobody knows you're a jerk.
Re: Converting from MKS Korn Shell to Linux
am 27.09.2007 01:18:22 von Janis Papanagnou
bsh wrote:
> Andra wrote:
>
>>[Kornshell on Linux]
>
> As far as the second option, I am in agreement with the
> recommendation by Janis. ksh93 is an excellent shell -- my
> favorite -- that is freely available in binary and source
> forms for many host systems, including the PC (under U/WIN).
I am using the linux.i386 ksh93 on my Linux PC (without UWIN).
(Likewise cygwin.i386 on a Windows PC at work w/o UWIN.)
Not sure, though, whether by U/WIN you mean Unix and/or Windows
or the UWIN product from AT&T for which there are own packages,
as far as I can see.
Janis
Re: Converting from MKS Korn Shell to Linux
am 04.11.2007 19:32:53 von Sven Mascheck
bsh wrote:
> "Portable Shell Programming":
> [autoconf documentation]
Keep in mind, that this guide aimes at _maximizing_ portability:
"[...] to prevent trouble, do not take advantage of features
that were added after UNIX version 7"
Nowadays, traditional portability means SVR2.
> "What to watch out for when writing portable shell scripts":
> http://www.linux.com/articles/34658
....by Peter Seebach even, but apparently he didn't consider Solaris,
"variable expansion rules using # and % [...] were introduced
in Korn shell, but are available in every /bin/sh I was able
to find today."