Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert this script to ksh ??

Status
Not open for further replies.

hokky

Technical User
Nov 9, 2006
170
AU
Hi guys,

I wanna convert this script which running in bash to ksh :

Code:
for ((i=0;i<=8;i++))
do
    echo $i
done

I don't wanna use while, I was just wondering how to use for in ksh for that case.

Thanks guys
 
That syntax is only supported in later versions of ksh.

If your ksh can't handle it, I think while is your best option.

Annihilannic.
 
Guys,

How to check the ksh version.
I typed ksh --version.

Didn't give me the version.

Do I need root access to install later version of ksh ?
 
To find the version of ksh, type this:

echo ${.sh.version}

If this prints a version, you are most likely using the 1993 (newer) ksh. If it gives an error, type this:

set -o emacs, followed by a CTRL-V

On my system, the above commands generate this:

host01:/ #echo ${.sh.version}
ksh: ${.sh.version}: 0403-011 The specified substitution is not valid for this command.

host01:/ #set -o emacs
host01:/ #Version M-11/16/88f


So I am running the 1988 version of ksh on my system.
 
Hi sbrews,

This is what I got following ur command :
# echo ${.sh.version}
-bash: ${.sh.version}: bad substitution
# set -o emacs^M
: invalid option name


Because I dont have emacs installed in my server, so I tried:

# set -o vi^M
: invalid option name

Same result, so any other idea ?
 
what shell are you using? Typically when I see the "invalid option" error, the shell is something other than ksh.

type: echo $SHELL

if you are using ksh, you should something like /usr/bin/ksh or /bin/ksh.

 
hokky said:
This is what I got following ur command :
# echo ${.sh.version}
-bash: ${.sh.version}: bad substitution

you are not in ksh but in bash

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top