procedure/function not found in .ksh

Hi all ,

I am getting an error "job_procfile not found" while excecuting a .ksh script. The script is used to create control-m ( scheduler ) jobs dynamically by reading parameter files ( flat filescomma seperated )

job_procfile is a function within the .ksh script

The script is something like this ...
script start *****
job_procfile
{
set string to call control-m job creation ( ctmcreate )
eval(string)
}

job_multiprocess
{
read parameter files and init values ( awk )

for loop based on multiple processes defined fo a stream
do
call job_procfile -----> (B)
done
}

loadstream
{
if some value
then
call job_procfile -----> (A)
else
call job_start
if value is multiprocess
then
call job_multiprocess
else
call job_procfile
fi
call job_success
fi
}

# main
read files in awk ( do search to get values )
call loadstream ( to load control-m streams )

script end *****

When job_procfile is called at (A) it works fine. But when called from within job_multiprocess (B) it comes up with the error message "job_procfile not found "

Any ideas ?

Thanks !

  1. confirm you have "#!/bin/ksh" as the start

  2. define your functions

funcname()
{
    blah
}

See if that helps.

yep,
have done both
Still get the error ...

what does "call" do?

sorry should have been more specific ..

I have mentioned the framework of the shell script i.e. not the entire script
"Call" refers to calling the sub routine ( procedure )

I the program itself its just

if [[ ..something ...]]
then
job_procfile ( i have written this down as call job_procfile for clarity )
fi

The entire script runs over 600 lines and if required I can paste it over here ...
Thanks .

Are you sure that every function is called after it is defined?

Have you tried debugging using

#!/bin/ksh -x

as the first line?

all functions have been defined . I have missed putting the () after function names in the pseudo code. The strange bit is that the function call works from within one of the if condition blocks , but comes up with this error message when called from within a function .

Tried to debug using -x but the output lists only the code outside the functions i.e. any code the functions is not listed.
I am working on AIX 5.3 on an IBM P590 .

Either

(a) produce a small script which does demonstrate the problem and post that without alteration, within [ CODE ] blocks so we can see it formatted.

(b) post the whole 600 line script

It may help to put the functions into external files:

  • create separate file for every function, named like the function and with filemode 644

  • put all these files into a directory

  • at the beginning of your main script set the variable "FPATH=" to the directory holding the functions. FPATH works similar to PATH, but tells the shell where it can find external functions instead of external executables. Export the variable FPATH after defining it

The files have to contain the same function definitions as if they would be included in the main scripts file for example, this would go into a file $FPATH/foo:

# first line of file foo
function foo
{
     # ... inside function foo ....

return <int>
}

This may not necessarily help in your specific case, but it might help in narrowing down the problem and finally find it.

bakunin