What is file descriptor 10?
5,087
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.
Related videos on Youtube
Author by
Peter Mortensen
Updated on September 18, 2022Comments
-
Peter Mortensen over 1 year
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).
-
user1686 almost 12 yearsHalf of the command doesn't make sense. It attempts to run a script from within a directory which it just
mkdir
'd... -
Peter Mortensen almost 12 years@grawity: the mkdir, etc. was executed on each of a number nodes in a Linux cluster - the command enclosed in ' s.
-
user1686 almost 12 yearsI'm aware of that. I was talking specifically about the
mkdir /home/mortense/sambapub;cd /home/mortense/sambapub;./runcola.sh
part. -
Peter Mortensen almost 12 years@grawity: yes, you are right. It was not well thought out (probably a mixup of two different stages).
-
-
user1686 almost 12 yearsThe syntax is
exec 10>afilename
in sh. -
Peter Mortensen almost 12 years@grawity: isn't possible to redirect to another file descriptor in sh?
-
Peter Mortensen almost 12 years@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.
-
user1686 almost 12 years@Peter: It is, with
10>&1
or similar.