Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is file descriptor 10?

Real-world example (where standard output is ignored, standard error redirected to standard output and data from file descriptor 10 is redirected to standard output) that I have lost the documentation/context for:

./cluexec21nodes 'mkdir /home/mortense/sambapub;cd /home/mortense/sambapub;./runcola.sh >/dev/null 2>&1 10>&1 &'

The standard file descriptors are

0   Standard Input (stdin)
1   Standard Output (stdout)
2   Standard Error (stderr)

but what is file descriptor 10?

This was used on a Linux system (possibly Red Hat).

share|improve this question
1  
Half of the command doesn't make sense. It attempts to run a script from within a directory which it just mkdir'd... –  grawity May 10 '12 at 12:47
    
@grawity: the mkdir, etc. was executed on each of a number nodes in a Linux cluster - the command enclosed in ' s. –  Peter Mortensen May 10 '12 at 13:22
    
I'm aware of that. I was talking specifically about the mkdir /home/mortense/sambapub;cd /home/mortense/sambapub;./runcola.sh part. –  grawity May 10 '12 at 13:27
    
@grawity: yes, you are right. It was not well thought out (probably a mixup of two different stages). –  Peter Mortensen May 10 '12 at 14:00

2 Answers 2

File descriptors are not fixed; the program may use them in whatever way it wants. (Even fd's 0-2 can be closed, opened, reused.)

In this case, fd 10 seems to be chosen arbitrarily; it could be that ./runcola.sh expects to be able to write some additional information to it. You'll have to read the script itself to know for sure.

share|improve this answer

Beyond the standard file descriptors there are 3-1024. These can be created in scripts with the

exec 10<> afilename

From this point on, anything written to file descriptor 10 gets written to afilename

When you have

./script.sh 10>&1 

You are redirecting anything that would have gone to file descriptor 10 to stdout.

You'll want to review the runcola.sh script to see why it is doing this.

share|improve this answer
    
The syntax is exec 10>afilename in sh. –  grawity May 10 '12 at 12:53
    
@grawity: isn't possible to redirect to another file descriptor in sh? –  Peter Mortensen May 10 '12 at 13:31
    
@Paul: it may have been an arbitrary convention that was used, but given it was used for executing a command on each of a number of nodes in a Linux cluster, couldn't it have something to do with that (network pipes?). Anyway, I will try to find the two scripts. –  Peter Mortensen May 10 '12 at 13:38
    
@Peter: It is, with 10>&1 or similar. –  grawity May 10 '12 at 13:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.