The problem is with the following line of code
Code:
LOG=$(f_open_log bigfile)
This causes the file descriptor to be closed. One workaround is to use a global variable as in the following example
Code:
#!/bin/ksh88
typeset -i fh
function open_log
{
next=${LOG_FH_COUNTER}
eval "exec ${next}>$1"
fh=${next}
print_log ${next} "Log file opened"
((LOG_FH_COUNTER=LOG_FH_COUNTER+1))
echo ${next}
}
function print_log
{
print -u$1 $2
}
typeset -i LOG_FH_COUNTER=3
open_log bigfile
print_log ${fh} "This is a test"
exit 0
|