The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 06-08-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,945
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