ksh -> sh conversion???

ksh -> sh conversion???

Post by Ron Watki » Sat, 07 May 1994 02:45:07



I have been given the unlikely task of converting over 80 pages of ksh
script into an sh script. It's a ksh script which runs on Ultrix, the one
which supports:
if [[ ]]; then
type of syntax. I believe it's the newer syntax which goes beyond pdksh style.
Anyhow, we need to convert this script to run on a SunOS 4.1.3 system.
I would like to find out if there is a ksh available with the advanced syntax
(whatever that ammounts to...) OR if anyone knows how to go about converting
the ksh script into sh style.
ANY pointers would be helpfull as im just a fledgling shell programmer with
little actual shell experience. We use for loops, while loops, wait, variaties
of regular expressions (I think these are rather universal :>) etc...
Im especially interested in exported shell variables, writing functions and
local variables in functions. We also have sections of code where we use
typeset in particular ways such as:
typeset -Z3 var
to get numbers such as 001, 002, 003...
Please offer any advice except that I shouldn't do it. I don't have a choice.

I have heard that there might be some sed scripts which will do most of the
work of conversion of syntax. I also need some kind of style or syntax guide
for sh. I have the Korn Shell (turtle) book from O'Reilly. I don't have access
to any sh books though. Do you know of any that I should get???
Thanks for any pointers.

                        Ron Watkins

--

931 Gould-Simpson                            /            /____/     /
University of Arizona                       /            /          /
Tucson AZ. 85721 -- (602) 621-8606         (____ unar & / lanetary (____ ab.

 
 
 

ksh -> sh conversion???

Post by P.A. Lopez-Valenc » Sun, 08 May 1994 12:22:14




> I have been given the unlikely task of converting over 80 pages of ksh
> script into an sh script. It's a ksh script which runs on Ultrix, the one
> which supports:
> if [[ ]]; then
> type of syntax. I believe it's the newer syntax which goes beyond pdksh style.
> Anyhow, we need to convert this script to run on a SunOS 4.1.3 system.
> I would like to find out if there is a ksh available with the advanced syntax
> (whatever that ammounts to...) OR if anyone knows how to go about converting
> the ksh script into sh style.
> ANY pointers would be helpfull as im just a fledgling shell programmer with
> little actual shell experience. We use for loops, while loops, wait, variaties
> of regular expressions (I think these are rather universal :>) etc...
> Im especially interested in exported shell variables, writing functions and
> local variables in functions. We also have sections of code where we use
> typeset in particular ways such as:
> typeset -Z3 var
> to get numbers such as 001, 002, 003...
> Please offer any advice except that I shouldn't do it. I don't have a choice.

> I have heard that there might be some sed scripts which will do most of the
> work of conversion of syntax. I also need some kind of style or syntax guide
> for sh. I have the Korn Shell (turtle) book from O'Reilly. I don't have access
> to any sh books though. Do you know of any that I should get???
> Thanks for any pointers.

There is a nice comparison article in May's Open Systems (former UnixWorld)
among the different shells. The command comparison tables for different
commands and syntax may give you clues to how to massage your script.

P
--

Landscape Ecologist, Conservation Biologist

             The meaning of life resides in unexpected places

 
 
 

ksh -> sh conversion???

Post by Jon Hamilt » Sun, 08 May 1994 19:08:41


[needs to make a ksh script run under SunOS 4.1.x, pdksh won't do]

Quote:>There is a nice comparison article in May's Open Systems (former UnixWorld)
>among the different shells. The command comparison tables for different
>commands and syntax may give you clues to how to massage your script.

I responded to the original poster vie email, but in case anyone else
is in a similar boat, bash will run "most" ksh scripts with little
if any manual intervention.  Bash is available from prep.ai.mit.edu
in /pub/gnu.
--
+----------------------------------------------------------------+

|   CS Solaris Systems Support Group, Iowa State University      |
+----------------------------------------------------------------+
 
 
 

ksh -> sh conversion???

Post by General Semantic » Thu, 12 May 1994 09:13:25


] I have been given the unlikely task of converting over 80 pages of ksh
] script into an sh script. It's a ksh script which runs on Ultrix, the one

Godd luck, aye?  The only advice I have is that the /bin/sh I have
(ultrix4.3) doesn't have functions (/bin/sh5 does).  But you can do
psudo-functions like this:
        JAMfunction='
                echo "this is sorta like a function"
                '

and then eval $JAMfunction to 'call' it... I think this forks off another
copy of sh to evaluate the string though.

--
   Will Scarlet: "Robin, are you thinking what I think you are thinking?"
                          Robin Hood: "I think so."

 
 
 

1. sh/ksh 1>&2 2>&1 !%^%#!!?

I'm missing some important trivial point here.  Perhaps someone could help?

I have a program which I'm calling from a ksh script.  I want to log the
program's standard output and error to the same file as might easily be
done with 'program 2>&1 | tee logfile'.  But I want the output and error of
the program to still come out of two seperate file descriptors (ie 1 and 2)
when the script spits it out to the user.

This is because I want the script transparent around the program.

It seems easy - what am I missing?  I want to interfere with the
natural output of the program as little as possible while logging.

Any suggestions via email please,

thanks, Nigel.

2. NT/Linux Dual Boot - NT Randomly Hangs

3. sh/ksh redirection 1> outfile 2>&1

4. Simple Hack To Get $2000 Watch Video.

5. sh var -> awk var -> sh var

6. Linux & #9 Motion FX 771 2 MB VRAM PCI

7. Script conversion from csh --> sh

8. terrible 3c509 performance

9. set conversion sh > csh

10. sh -> csh conversion problem

11. Conversion/Utility Unix .sh -> mac?

12. sh->xqf->quake works, fvwm->xqf->quake hangs X?

13. tcsh -> ksh alias conversion