All Questions

Tagged with
Filter by
Sorted by
Tagged with
0
votes
0answers
23 views

Understanding anonymous pipe ID

I'm currently debugging a system which has a resource leak. It seems that we have too many pipse open. When I go the my /proc/PROC_ID/fd I see the list of pipes l-wx------ 1 root root 64 Jun 30 12:32 ...
0
votes
0answers
32 views

Separate stdout of an application

I have an application that takes a few command line parameters, then prints some text to the terminal, then starts writing data to a file. It has a parameter I can use to define the file name to write ...
1
vote
2answers
45 views

Flush the pipe/printf buffers externally for already running process with known PID

I am writing a data logging app, all programs are started like: ./program > out.bin The data collector periodically pools the stdout output files and reads the data. The issue is that the IO ...
2
votes
1answer
79 views

Understanding pipes and redirections in dash

Someone asked how to pass the output of two commands as files to another command and they got the answer below. ( cmd1 | ( cmd2 | ( main_command /dev/fd/3 /dev/fd/4 ) 4<&0 ) 3<&0 ) I ...
0
votes
1answer
98 views

Multiple fifos over SSH

Shell script allow multiple file descriptors (up to 9 for POSIX compliance, but even more for bash): $ install -m 755 /dev/stdin /tmp/test <<\EOF #!/bin/sh echo hi1 >&1 echo hi2 >&...
0
votes
2answers
79 views

STDOUT + STDERR output … is there any difference between considering the output to be an empty string vs NULL

I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). ...
1
vote
1answer
47 views

A command wants file paths. How can I give it stdin for the “infile” and stdout for the “outfile”?

Consider a command like foo -in /path/to/infile -out /path/to/outfile, that you'd like to pass strings to rather than using temp files. It may be called a lot causing much disk access, or is related ...
1
vote
1answer
583 views

Effect on the shell pipe operator on stdin, stdout and stderr

When I create a pipe using the shell, for example: ls | cat What I know for sure is that the stdin for cat will be the stdout for ls (i.e. everything ls writes to its stdout, cat will read it ...
5
votes
4answers
4k views

Why is there a “/dev/fd/63” in the output of “echo 123 >(cat)”?

$ echo 123 | cat 123 is doing what I expected, both commands run inside the same shell. But when I connect them with the >( ... ) expression, which connects the output of one command in the ...
1
vote
1answer
198 views

Byte Offsets for pipe/FIFO

Why are byte offsets for a pipe/FIFO maintained in the inode rather than the file table, like for regular files? I read this line at page 113 of The Design of The Unix Operating System (1986) by ...
1
vote
0answers
384 views

Read from an arbitrary fd of a running process

I have two processes A and B, communicating over a pipe. I would like to be able to read from that pipe, using lsof I can easily find the right fd, unfortunately tail -f /proc/$pid/fd/$fd doesn't seem ...
2
votes
1answer
1k views

How to read a webcam that is already used by a background capture?

A ffmpeg webcam capture is running in the background. ffmpeg -f video4linux2 -s vga -i /dev/video0 capture.mp4 (1) I am therefore unable to read it with ffplay since the device /dev/video0 is ...
1
vote
0answers
642 views

How to fork a ffmpeg stream in order to read it with ffplay?

Say I create an encrypted webcam capture ffmpeg -f alsa -ac 2 -i plughw:0,0 \ -f video4linux2 -s vga -i /dev/video0 \ -f ogg >(openssl enc -k $PASSWORD -aes-256-cbc -out webcam.aes-256-cbc How ...
6
votes
2answers
363 views

dash: Pipe STDIN to multiple commands and their output to STDOUT in defined order

At first I thought this answer was the solution, but now I think I need a temporary file as buffer. This works unreliably: #!/bin/sh echo 'OK' | { { tee /dev/fd/3 | head --bytes=1 >&...
5
votes
1answer
967 views

Opening named pipe blocks forever, if pipe is deleted without being connected

Try the following shell commands: mkfifo /tmp/test.pipe ls -1 /tmp > /tmp/test.pipe & rm /tmp/test.pipe mkfifo /tmp/test.pipe cat /tmp/test.pipe & jobs The ls command is just an ...
17
votes
1answer
3k views

How to terminate a TCP connection established by bash itself?

I have used exec 3<>/dev/tcp/192.168.0.101/6435 to establish a TCP connection with 192.168.0.101:6435. And I have received as well as sent a few messages with the pipe command. Now, I want to ...
3
votes
2answers
117 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with >(cmd)...
12
votes
2answers
2k views

SSH: Provide additional “pipe” fds in addition to stdin, stdout, stderr

When connecting to a host with SSH, usually three "pipes" are provided between host and guest, for stdin, stdout, and stderr. Is there a command-line option to create forwards for additional file ...
9
votes
2answers
3k 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
438 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
6
votes
2answers
799 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 ...
3
votes
3answers
2k 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
3answers
445 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. Of ...
2
votes
2answers
520 views

stop pipe() opening stdin

I've currently got code that forks two processes. The first reads a http streaming radio and pushes the data down a pipe (opened with pipe() ) for the second process to read, decode and output to the ...