The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
0answers
4 views

Capturing data from a Fluke 1620a via Bash /dev/tcp file descriptor

I am currently trying to develop a script that will connect to a Fluke DewK 1620a Themo-Hygrometer and pull the current temperature and humidity readings from the device. While these devices have a ...
2
votes
2answers
102 views

How to print total number of file descriptors with index 24

How can I print the total number of file descriptors with index 24 for all the running processes on Linux? I tried $ ls /proc/*/fd 2> errors.txt > stdout.txt | grep "^24" stdout.txt | wc -l ...
3
votes
2answers
66 views

How to read user input when using script in pipe

General problem I want to write a script that interacts with the user even though it is in the middle of a chain of pipes. Concrete example Concretely, it takes a file or stdin, displays lines ...
2
votes
1answer
20 views

Forcing write(2) to return 0

I am writing unit tests and would like to test some code's handling of the case where a call to write(2) returns zero. As ever, it would be nice to keep the test as authentic as possible. I can use a ...
1
vote
0answers
33 views

open() sys call [closed]

Process A wants to open a file fd1 = open("/var/file1", O_RDONLY); In the process of opening file1 which table is referred first system wide file table or file descriptor table or in-core inode ...
2
votes
5answers
273 views

Stripping directory paths to get file names

What I am doing is converting mp3's with LAME. I already have an old script I wrote that works but I want to add to it this ability--to no longer delete the file but instead save it in a new root ...
46
votes
2answers
2k views

Is >&- more efficient than >/dev/null?

Yesterday I read this SO comment which says that in the shell (at least bash) >&- "has the same result as" >/dev/null. That comment actually refers to the ABS guide as the source of its ...
0
votes
1answer
35 views

How to find file/device given the resource ID on Linux?

On a gentoo Linux system I am printing the value of a file descriptor from within a PHP script yielding the following output: Resource id #1234 How to find the corresponding file/device given this ...
1
vote
2answers
128 views

Process substitution with input redirection

I am trying to understand input redirection in combination with process substituation. I am using bash 3 An example with tr is the following $ tr "o" "a" <(echo "Foo") tr: extra operand ...
5
votes
3answers
591 views

Why can't I `tail -f /proc/$pid/fd/1`?

I wrote a simple script which echo-es its PID: #/bin/bash while true; do echo $$; sleep 0.5; done I'm running said script (it says 3844 over and over) in one terminal and trying to tail ...
2
votes
1answer
52 views

Is there a system call to bind a file descriptor directly into another?

A read() & write() loop would probably be as good as what I'm looking for, but nevertheless is anything like that around or is it impossible because of an obstacle I didn't envisage ? I'm curious
7
votes
1answer
68 views

How can I send reads and writes on a single file descriptor to different places?

I have a Linux executable foo that reads input from fd 0 and writes output to fd 0 (not fd 1). This works just fine for interactive use in the terminal. From the shell command line, how can I execute ...
7
votes
3answers
632 views

How can a log program continue to log to a deleted file?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section: If an active process has the file open (not uncommon for log files), removing the file and creating a new ...
5
votes
2answers
108 views

“command | less” vs “less <(command)”

A common "idiom" for viewing large amounts of command output is to pipe it to less, via command | less. However, it's also possible (perhaps only in bash, haven't tested in other shells) to use the ...
1
vote
2answers
60 views

What fd's are used when doing diff <(cat old) <(cat new)?

If I do: diff <(cat old) <(cat new) Hoe does that work internally for the diff program? And how I do the same trick with a bash script?
8
votes
1answer
357 views

stderr over ssh -t

This sends output to STDERR, but does not propagate Ctrl+C (i.e. Ctrl+C will kill ssh but not the remote sleep): $ ssh localhost 'sleep 100;echo foo ">&2"' This propagates Ctrl+C (i.e. ...
2
votes
0answers
16 views

Is it safe to create a regression test that relies on running out of file descriptor limit?

I'm writing a regression test for my modification of Nmap and I'm wondering if it's a good idea to create a test that would basically perform a large-scale connect() scan on 127.0.0.1/8, which would ...
2
votes
2answers
274 views

Any way in Bash to write to a file every X seconds without closing it?

The hardware watchdog on my system needs a 0 written to /dev/watchdog at less than 60 seconds interval or it will fire. The file handle must be kept open however or the watchdog is then disabled. ...
2
votes
1answer
263 views

closing the unwanted file descriptors

I am trying to understand how pipes work . This code snippet is from some website . So my understanding of the program goes like this : When we do pipe(fd) then fd[0]=3 and fd[0]=4 ( assuming only ...
3
votes
0answers
64 views

Some puzzles of how to close file descriptors on sh or bash [duplicate]

Question 1. What will happen if we close a input file descriptor as if it is a output file descriptor? (or vice versa). For Example, $ exec 5<&2 $ exec 5>&- In my linux box, ...
4
votes
2answers
726 views

Process substitution from curl to bash as root

I'm trying to run a script from URL as root with this command: sudo bash <(curl -s http://copy.com/gLVZIqUubzcS/popcorn) But I'm getting this error: bash: /dev/fd/63: Aucun fichier ou dossier ...
5
votes
2answers
621 views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
2
votes
4answers
108 views

Can a running script identify the logging context?

Let us say I redirect the STDOUT, STDERR of a program to files. ./script.sh 1> output.log 2> error.log Can the running program find this out i.e. know the paths to these files?
3
votes
2answers
2k views

Close all file descriptors in bash

Is there a way to close all the open file descriptors, without having an explicit list of them beforehand?
2
votes
3answers
167 views

Redirecting only stderr to a pipe

This code snippet is from Advanced Bash Scripting Guide. # Redirecting only stderr to a pipe. exec 3>&1 # Save current "value" of stdout. ls -l 2>&1 ...
4
votes
1answer
676 views

What does exec 3<&1 do?

I understand exec can do I/O Redirection on current shell level. but I only sees usage like exec 6<&0 # Link file descriptor #6 with stdin. # Saves stdin. exec 6>&1 # ...
0
votes
2answers
226 views

How to reset the file descriptor

I was trying to use file descriptor for printing the lines in the file #!/usr/bin/ksh exec 3<&0 exec 0< file.txt while read LINE do echo “$LINE” done and I am done with my code ,it ...
4
votes
3answers
761 views

Please help explain this bash output redirection

This script was posted as answer to a Question. And I'm trying to work out what's going on. result=$( { { ssh host app-status >&3 3>&-; echo "$?" } | { until read ...
3
votes
1answer
78 views

What is the relationship between a program's output, standard output, and its file descriptors?

Let's assume that I am running wget which is downloading something. It's printing some text to my terminal and writes the downloaded data into a file. From a terminology point of view, what is the ...
1
vote
0answers
225 views

Which socket is gnome-shell reading from continuously?

strace shows that the GNOME shell is continuously trying to read from a socket, which is often not available (or doesn't contain any data to read from): strace -p gnome-shell-pid -e trace=recvfrom ...
11
votes
2answers
222 views

Output order with process substitution

This is what I usually do to run grep and wc on a file without having to scan it twice <file.txt tee >(grep LITERAL) >(wc -l) >/dev/null However, this yields EXEC LITERAL 32 ...
4
votes
2answers
555 views

Does OpenBSD have a limit to the number of file descriptors?

What's the maximum number of file descriptors that a process can get on OpenBSD successfully? For example, there is an openfiles limit in login.conf(5) in OpenBSD. If I want to have as many file ...
3
votes
3answers
102 views

Print a message from the left-hand side of a pipe

I want to use a variable from the main shell in a sub shell. I did: export mysql_root_password="test" ( echo $mysql_root_password ) | dialog --gauge "Working hard..." 6 50 There is no output. ...
4
votes
1answer
338 views

Why doesn't the process substitution <() work with ssh -F

I have some vagrant virtual machines. To log into them I issue the vagrant ssh command. I want to log into them using regular ssh command. The vagrant ssh-config outputs the suitable config file $ ...
2
votes
2answers
440 views

AIX open() : file descriptor is zero (!?)

A daemon process, on detecting the presence of a text file in a particular directory then launches an executable file which opens the aforementioned text file in order to read and then transmit its ...
5
votes
1answer
109 views

Replacing stdout with stderr

Is it possible to redirect the output from a command to replace the text sent to stdout with the text from stderr? $ ./script this line is redirected to stdout this line is redirected to stderr $ ...
3
votes
2answers
1k views

File descriptor and fork

When a child is forked then it inherits parent's file descriptors, if child closes the file descriptor what will happen ? If child starts writing what shall happen to the file at the parent's end ? ...
6
votes
1answer
3k views

How to circumvent “Too many open files” in debian

If I want to see all relevant log files of my apache2 server at once, I use tail -f /var/kunden/logs/*log /var/kunden/logs/*log /var/log/apache2/*log |grep -v robots|grep -v favicon But since those ...
5
votes
1answer
3k views

Limits on the number of file descriptors

I'm trying to install 389-ds, And it gives me this warning : WARNING: There are only 1024 file descriptors (hard limit) available, which limit the number of simultaneous connections. I understand ...
2
votes
1answer
2k views

How to find speed of wlan interface?

I'm trying to find speed of network interface using file-descriptor. It's easy to do it for ethX, just calling cat /sys/class/net/eth0/speed. Unfortunately this method doesn't work with wireless ...
4
votes
2answers
531 views

Cross-process dup on Linux

I'd like to dup a file descriptor running in an unrelated process on Linux. I know about sendmsg(2) and SCM_RIGHTS (e.g. ...
4
votes
3answers
1k views

Something's special about /dev/fd/3

I've been trying to learn about file descriptors. When I type "ls -l /dev/fd/" I get lrwx------ 1 me users 64 May 2 16:02 0 -> /dev/pts/5 l-wx------ 1 me users 64 May 2 16:02 1 -> ...
1
vote
3answers
1k views

How to check which process is using a given file descriptor?

Somewhere in the middle of my application, the framework I'm using (ROOT) gives me the following error: *** Break *** write on a pipe with no one to read it SysError in ...
2
votes
1answer
348 views

open() console for default file descriptors

I'm reading a shell program implementation in C ( the xv6 shell from MIT's 6.828 Operating System Engineering course ). The main() function for this shell starts with the following code: //Assumes ...
17
votes
2answers
15k views

Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

Just looking for the difference between 2>&- 2>/dev/null |& &>/dev/null >/dev/null 2>&1 and their portability with non-Bourne shells like tcsh, mksh, etc.
1
vote
1answer
525 views

Understand file descriptors and nodejs

I'm having a bit of a confused time understanding what a file descriptor is and if I even need one! I am trying to spawn a process in nodejs and have its out put be written directly to an out put ...
2
votes
1answer
150 views

Why is it possible to refer to a closed stderr under bash?

I'd like to know why bash doesn't display an error message when we refer to a closed stderr. When it comes to other file descriptors, they have to be opened if we want to, for example, duplicate them. ...
12
votes
3answers
902 views

Practical use for moving file descriptors

According to the bash man page: The redirection operator [n]<&digit- moves the file descriptor digit to file descriptor n, or the standard input (file descriptor 0) if n is ...
3
votes
1answer
268 views

Significance of arrows symbols in duplicating/closing file descriptors under bash

I'm reading a book about Linux command line where author doesn't seem to follow the conventions in bash manual regarding arrows symbols used in redirection operations. Namely, he always uses left ...
3
votes
2answers
837 views

What sets a child's STDERR, STDOUT, and STDIN?

If a program runs fork() what sets standard streams STDOUT, STDIN and STDERR?