Problem in running a shell script

Hi,

I'm trying to run a simple shell script whose contents are pasted below.

#!/usr/bin/ksh
echo $PATH
performbuild
{
echo "Inside performBuild function"
}
echo "Main Shell started"
performbuild
echo "Main Shell ended"

DV> ls -ltr
total 48
-rwxr-xr-x 1 pb5377 it-ibm 145 Mar 16 17:50 test_upd.sh
-rwxr-xr-x 1 pb5377 it-ibm 144 Mar 16 19:11 test1.sh
-rwxr-xr-x 1 pb5377 it-ibm 156 Mar 16 19:37 test.sh
DV> ./test.sh
ksh: ./test.sh: not found
DV>

If at all if the script gets executed, it is not recognizing the function and the commands in the script get executed sequentially.
The output looks like

DV> ./test.sh
/usr/bin:/sbin:/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/ucb:/usr/local/bin:/usr/local/sbin:/usr/sfw/bin:/opt/VRTS/bin:/usr/local/bin:/usr/local/sbin:/usr/ccs/bin
./test.sh[5]: performbuild: not found
Inside performBuild function
Main Shell started
./test.sh[11]: performbuild: not found
Main Shell ended
DV>

Any help is appreciated

Thanks,
blp

The general format for declaring a function is

function function_name()

So you need to write like

#!/usr/bin/ksh
echo $PATH
function performbuild()
{
        echo "Inside performBuild function"
}
echo "Main Shell started"
performbuild
echo "Main Shell ended"

The sample output I got is:

/home/thillaiselvan:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:.:/home/thillaiselvan/.vim/ctags-5.7/
Main Shell started
Inside performBuild function
Main Shell ended
$ 
$ cat -n f5.ksh
     1  #!/bin/ksh
     2  echo "hello, world!"
     3  performbuild()
     4  {
     5  echo "Inside performBuild function"
     6  }
     7  echo "Main Shell started"
     8  performbuild
     9  echo "Main Shell ended"
$ 
$ ./f5.ksh
hello, world!
Main Shell started
Inside performBuild function
Main Shell ended
$ 
$ 

tyler_durden

Thanks for the reply. I tried the same. But, I get an error

./test5.sh[4]: syntax error at line 3 : `(' unexpected .

Thanks,
blp

What's the output of the following command on your system ?

which ksh

and what does your script look like ?

tyler_durden

Thanks Tyler_Durden for your reply. I got it worked now. The problem is that some funky/control characters were came in with the file and they were causing the problem initially.

I tried this way

$ dos2unix <filename> > <destfile>

Thanks,
blp