The UNIX and Linux Forums  

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File Descriptor Table Ashaman0 UNIX for Advanced & Expert Users 6 12-03-2007 02:54 PM
File descriptor constant vino High Level Programming 4 05-18-2005 02:18 AM
File Descriptor Help rahulrathod UNIX for Dummies Questions & Answers 3 10-14-2004 06:08 AM
file activity (open/closed) file descriptor info using KORN shell scripting Gary Dunn UNIX for Dummies Questions & Answers 3 06-07-2004 02:54 PM
bad file descriptor? ftb UNIX for Dummies Questions & Answers 1 02-20-2002 07:19 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-04-2008
robotball robotball is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 8
Question Passing a file descriptor

I am trying to right a function which uses a file descriptor to write to a log file. The problem is that the on the print statement the file descriptor is called bad. Now when I first open the file and print to it in the f_open function by passing the descriptor to f_print_log all works well, however when I returned the file descriptor to logtest.sh and then try to pass it to f_print_log I get bad file descriptor. Any help would be appreciated. Here are my functions and calling script:

********* THESE FUNCTIONS ARE IN f_log.sh
function f_open_log
{
next_fh=$LOG_FH_COUNTER
eval "exec $next_fh>$1"

f_print_log $next_fh "Log file opened"
(( LOG_FH_COUNTER=LOG_FH_COUNTER + 1 ))

echo ${next_fh}
return 0
}

function f_print_log
{
print -u$1 $2
return 0
}
***************************************************

logtest.sh -->

#!/bin/ksh

. f_log.sh

typeset -i LOG_FH_COUNTER=3

LOG=$(f_open_log bigfile)
f_print_log $LOG "This is a test"

exit
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0