Calling Function Problem

Hi,

I had a scripts which calls two function. One function will call another function, script is working fine but the second function is not calling the first function. Below is the script

#!/usr/bin/ksh
fun1() {
echo $DATETIME >> Test1.ksh
return 0
}
fun2() {
typeset DATETIME=`date +%Y%m%d' '%T`
fun1
return 0
}

When I run the above script in which I'm calling fun1 in fun2. But I'm not able to see any data in Test1.ksh and it is a zero size file. Help me in understanding why the DATETIME was not written to Test1.ksh file.

Thanks,
Raju

That script doesn't call either function.

Why it will not call either function. I'm I doing any thing wrong in my script.

Because you never told it to.

Yes.

fun1() {
echo $DATETIME >> Test1.ksh
return 0
}
fun2() {
typeset DATETIME=`date +%Y%m%d' '%T`
fun1
return 0
}

fun2  # <-- call function fun2
# cat Test1.ksh
20091121 17:55:47

You need a line in the script that calls fun2. Add:

fun2

Thank you very much. It is working now.