compile a shell script

How can i compile a KSH shell script. I Dont want to execute it. I just need to compile it .

Any Help sincerly appreciated.

Get shc.

no i can't go for Shc as it is not installed and i am not sure whether it is supported by ksh...

Any other way ?...

It is not supporting ksh? Where did you read that?

root@isau02:/data/tmp/testfeld> cat mach.ksh
#!/usr/bin/ksh

echo "Some menue"
echo

PS3="Choose a number: "

select CHOICE in one two three four quit
do
  case $CHOICE in
        one)    echo 1;;
        two)    echo 2;;
        three)  echo 3;;
        four)   echo 4;;
        quit)   exit ;;
        *)  echo "\nTry again\n";;
  esac
done

exit 0
root@isau02:/data/tmp/testfeld> ./mach.ksh
Some menue

1) one
2) two
3) three
4) four
5) quit
Choose a number: 2
2
Choose a number: 4
4
Choose a number: 5
root@isau02:/data/tmp/testfeld> shc -f mach.ksh
root@isau02:/data/tmp/testfeld> ll mach*
-rwx------ 1 root root   253 2008-12-16 12:43 mach.ksh
-rwx--x--x 1 root root  8444 2008-12-16 12:43 mach.ksh.x
-rw-r--r-- 1 root root 10725 2008-12-16 12:43 mach.ksh.x.c
root@isau02:/data/tmp/testfeld> ./mach.ksh.x
Some menue

1) one
2) two
3) three
4) four
5) quit
Choose a number: 2
2
Choose a number: 4
4
Choose a number: 5
root@isau02:/data/tmp/testfeld> file ./mach.ksh.x
./mach.ksh.x: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/Linux 2.4.1, stripped

Seems it supports ksh. I used "select" which is not available in bash afaik.

Hi Zaxxon ,

Thanks For the Reply.. as i said i can't go for Shc as it is not installed in my server . I am getting error message when i use shc.
Sorry for my misinterpretation that it is not supported by ksh.Since it is not installed in my server i thought wrong.

Yes I saw that you don't have it installed. But showing it works with ksh could have made you installing/compiling it or something so.. :slight_smile:
I know no alternative. Maybe write it in perl and compile it with perlcc or directly in C. Maybe someone else comes up with another suggestion.