The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing a file descriptor robotball Shell Programming and Scripting 6 06-08-2008 07:41 PM
File descriptor constant vino High Level Programming 4 05-17-2005 10:18 PM
Problems with file descriptor teo High Level Programming 11 05-09-2005 08:47 AM
file activity (open/closed) file descriptor info using KORN shell scripting Gary Dunn UNIX for Dummies Questions & Answers 3 06-07-2004 10:54 AM
bad file descriptor? ftb UNIX for Dummies Questions & Answers 1 02-20-2002 04:19 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-13-2004
Registered User
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 156
Question File Descriptor Help

What is a file descriptor in Unix??

How to find a file descriptor of a file in Unix??

Does it have anything to do with the Inode numbers??
Reply With Quote
Forum Sponsor
  #2  
Old 10-13-2004
Registered User
 

Join Date: Oct 2004
Posts: 235
file

Rathore
u c an use stat structure and find it
arun
Reply With Quote
  #3  
Old 10-14-2004
Registered User
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 156
Mr Arun Thanks for ur reply.

But i dint get it still.

Where is this stat structure located. Is it a command.
If it is it does n't run in SCO unix.

if it is a file where is it located.
Reply With Quote
  #4  
Old 10-14-2004
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
If you are familiar with UNIX I/O redirection, syntax similar to the following should not be new to you:
command > file 2>&1
When command runs it sends "normal" output to file, and any error messages generated by command are also written to file. "2>&1" handles the latter.

The 2 and 1 are file descriptors. So what's a file descriptor?

When a UNIX program wants to use a file, it must first open that file. When it does so, UNIX will associate a number with the file. This number, which is used by the program when reading from and writing to the file, is the file descriptor.

A typical UNIX program will open three files when it starts. These files are:

- standard input (also known as stdin)
- standard output (also known as stdout)
- standard error (also known as stderr)

Standard input has a file descriptor of 0, standard output uses 1, and the number 2 is used by standard error.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0