Questions tagged [pipe]

A Unix pipe connects file descriptors of two processes. A pipe is created with the POSIX pipe() function declared in <unistd.h>. Shells provide pipe creation between processes using "|".

130 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11
votes
1answer
979 views

zsh can't input to terminal when piping stdin and stdout with variable command that has tty output

System info: macOS Sierra 10.12.6 zsh 5.4.2 (x86_64-apple-darwin16.7.0) GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0) Scroll to the EXAMPLES at the bottom if you just want to dig ...
4
votes
1answer
52 views

Restore interactive commands after accidentally overpaging pipe input to less?

Consider a script like this: $ cat example.sh #! /usr/bin/env bash for i in {1..90} do printf '%s\n' "$i" done sleep 10 printf '91\n' sleep 10 printf 'done\n' and suppose the output is piped to ...
4
votes
0answers
501 views

two piped commands, each needs to read password from stdin

Is there a way to sensibly do this: scp user@host:/path/to/file /dev/tty | openssl [options] | less without creating a file, and without having to supply either password directly in arguments? The ...
4
votes
0answers
723 views

Understanding inotifywait, pipes and buffers

I want to monitor every file change in a directory with inotifywait. inotifywait shall write to a FIFO buffer, which then can be read, leisurely. While experimenting with relatively huge amounts of ...
4
votes
0answers
775 views

Scripted write-then-read from Unix domain socket using socat

I have a simple server listening on a Unix domain socket (on a CentOS box in case that's important). When I send the command "DATE" to the socket it writes back a welcome message and then "APRIL 15 ...
3
votes
0answers
483 views

write error: broken pipe with lemonbar script

I'm trying to pipe a bar script into lemonbar in bspwm. In my bspwmrc I have: ~/.config/bspwm/lemonbar.sh | lemonbar -p lemonbar.sh contains: #!/bin/bash clock() { date +%H:%M:%S } while ...
3
votes
1answer
362 views

When can I modify a page that was GIFT'd to vmsplice?

When vmsplice(4) is used with SPLICE_F_GIFT it is promised that my process won't modify the underlying page(s) I gift. The normal work flow I'm informed is: /*pseudo code don't kill me*/ void* page = ...
3
votes
4answers
543 views

How to detect an error using process substitution

This question is similar to the following link, but focused on using the command line (bash shell). Using a simple example, when doing the following command: $ cat <(date); echo $? Fri Jul 7 21:...
2
votes
0answers
21 views

Avoid pipeline stalls from write caching to usb drive

I have the following process I use for backups: btrfs send snapshots/home-2016-06-04 | zstd --verbose -T4 - | gpg --batch --passphrase-file /tmp/secret --compress-algo none --symmetric - > /mnt/...
2
votes
1answer
63 views

Cat blocking when piping output from /usr/bin/gssproxy (`timeout -k 1 1 /usr/bin/gssproxy | cat` does not terminate)

I use gssproxy under Arch Linux, in particular Name : gssproxy Version : 0.8.0-1 I encountered the following behavior: When trying to pipe the output of /usr/bin/gssproxy like ...
2
votes
1answer
190 views

How can I write directly to a Solaris FIFO pipe over ssh?

I have a Solaris server running a process that has its input and output redirected into FIFO pipes (fifo_in, fifo_out). How can I connect to these two pipes over ssh? I would like to be able to ...
2
votes
0answers
90 views

Knowing when bash is done running a command through a FIFO pipe

I'm trying to link a web-based terminal with bash. My current attempt to do so is spawning a shell pointing a FIFO pipe to its input, like this: Terminal 1 $ mkfifo pipe $ bash <> pipe file1 ...
2
votes
0answers
134 views

How can I pipe stdin inputs to command which expects multiple stdin inputs?

yes mypassword | while true; do sudo -S sleep 3; sudo -k; done can supply multiple identical stdin inputs mypassword to the while loop. When both sudo -S and the command it executes need different ...
2
votes
0answers
581 views

How can I send stdout to multiple commands in fish shell?

Same question as How can I send stdout to multiple commands? but for fish shell.
2
votes
0answers
135 views

How to control mysql with zpty?

I try to write a wrapper script for the mysql console client. While working on this, I stumbled upon zpty. It seems perfect. My first goal was to retrieve some table contents, but I already fail ...
2
votes
1answer
180 views

Piping config file to genkernel

I'm a gentoo user and I've become I a bit tired of copying my kernel config file when a new kernel comes out. I wonder if it's possible to pipe the configuration file to genkernel directly. Something ...
2
votes
2answers
754 views

How to format streaming JSON output from Node.js?

I have a Node.js server that uses JSON logging. When running the server locally, it outputs log entries as JSON objects which are quite tedious to read. I would like to pipe the output through a ...
2
votes
1answer
381 views

pipe speed benchmark with machine readable output

I'm looking for a tool similar to pv which is producing machine readable output. I can't believe that nobody did it before. I looked at the manpages of pv, pipemeter, dd and cpipe, but all these ...
2
votes
0answers
95 views

Close All Piped Commands if one close

I'm running at least 3 commands (with progs) using pipes. For example program1 bla bla | program2 blabla | program3 bla bla Is possible to close all programX PIDS automatically if at least one exits/...
2
votes
1answer
472 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
2
votes
0answers
854 views

avconv/ffmpeg output through /dev/ttyAMA0

I tried to pipe streaming video from video4linux2 webcam connected to a Raspberry Pi through /dev/ttyAMA0 to a computer using an Arduino as a intermediary. First of all, is it possible? Because I was ...
2
votes
1answer
2k views

How to redirect and use the framebuffer?

I need to work on the framebuffer to record what is being rendered. Now, I figure out how to convert the framebuffer in an image, I'm currently unable to obtain a constant stream of data from the fb ...
2
votes
0answers
250 views

Automatically start named pipe reader on startup?

I'm trying to run a script with root access from PHP. I can't do that because Apache's user, www-data, don't have root access because of security reasons. To fix that, I was advised to use a named ...
1
vote
1answer
113 views

How can a command within a pipeline abort the pipeline?

Given the pipeline a | b | c how might I alter b so that it aborts the pipeline if b generates an error or matches a particular pattern in the input stream?
1
vote
2answers
205 views

Send mail on change of line in log file, tail -f piping to mail doesn't work

I have a nginx access.log There is very infrequent traffic, so I want to get a mail on each access. I've tried tail -f access.log | cat That works. So piping with tail seems ok. With following ...
1
vote
0answers
69 views

Getting PID of sibling process in pipeline

I want to discover the PID of the producer process in a pipeline: producer | consumer I don't always control the producer process, I can request that they echo the PID from the producer like so: ...
1
vote
1answer
56 views

avoid bash buffering problem in log processing

I have bash buffering a problem similar to what can be found here: Turn off buffering in pipe The socat solution in the above question is quite interesting as I have access to this command in my ...
1
vote
1answer
237 views

How can I get feh to set wallpaper to each monitor according to its size?

I have a directory filled with png files $ tree ~/wallpaper/ ~/wallpaper/ ├── foo--1366x768.png ├── foo--1920x1080.png ├── foo--2048x1080.png ├── foo--3440x1440.png └── foo--3840x2160.png 0 ...
1
vote
0answers
30 views

How can I create a function that memoizes other commands?

I have created the following function to memoize any command: # zsh (( $+functions[ec] )) || { ec() print -r -- "$@" ecerr() { ec "$@" 1>&2 } ecdbg() ecerr "$@" gq() { ec "${(q+...
1
vote
0answers
112 views

When piping to a command via tee, output of first command is lost

The following command displays output of only grep command. df|tee >(head -1) |grep -i '/dev' whereas the following command gives output of both grep and head command df|tee >(head -1) >(...
1
vote
0answers
62 views

Unbuffer converting all characters to bell?

When I pipe a large-ish output through unbuffer, all I end up getting is an endless stream of the bell character (u0007). See here, a 1631-character string of arbitrary content piped through unbuffer ...
1
vote
1answer
50 views

Pipe stderr only if a terminal application crashes

I have a program which interacts with the user on the terminal. But if it crashes I'd like to pipe the stderr through another tool to tidy / prettyprint it. Is there a way to do this? As far as I ...
1
vote
0answers
124 views

Killing a process when some other process is finished

Given a | b, i'd like to kill b when a is finished. b is an interactive process, which doesn't terminates when a is finished (fzf in my case), and the whole a | b is executed in a $() subshell. So ...
1
vote
1answer
661 views

tail: error writing 'standard output': Broken pipe

I tried to use some scripts which use tail commands on Debian stretch but I got tail: error writing 'standard output': Broken pipe. Does Debian handle tail and pipe syntax differently? Thank you in ...
1
vote
1answer
198 views

socat and gawk piped

I'm trying to manipulate a TCP stream using gawk. The TCP server streams out a text string separated by whitespaces. I want to add an extra string at the beginning and then separate the remaining ...
1
vote
1answer
421 views

Read stdin and pass through pipeline to tee

I'm playing around with xinput to watch keyboard events. I'd like to transform the output with awk and pass it to tee, printing to stdout and writing to a file simultaneously. I watch events on ...
1
vote
0answers
320 views

See the overall percentage completion of a recursive cp command

Is it a simple way to track the completion of a large cp -r command? To get something like: copying 10% ... copying 20% Maybe using a pipe to another command? cp -rvv orig dest | show_as_percent ...
1
vote
0answers
135 views

Piping to another program in the middle of a oneliner

I'm trying to create a simple bash one line script that allows me to pick a particular barcode that's visible on my screen and make it available as text on my clipboard. To that effect, I wrote a bash ...
1
vote
0answers
46 views

“Inflate” a stream to guarantee demanded rate

Consider this pipeline schema: producer | consumer consumer: "realtime" process that "sets the pace" and if it can't consume N bytes/second, fails. (Examples: sound card, SDR, etc.) producer: this ...
1
vote
0answers
533 views

Why can't I pipe to parallel?

I have been trying to pipe this command tail -n +$line $FILENAME to this command parallel -a $FILENAME -k --block $sub --pipe-part "cut -d ' ' -f1" | sponge $FILENAME And the resulting command is ...
1
vote
1answer
508 views

Shell scripts connected with pipe: trap termination of one script

I have two shell scripts, one runs on a server and writes some files to a temporary directory. This directory is then sent as a tar archive to stdout. At the end (or when it gets interrupted), the ...
1
vote
0answers
68 views

What's wrong with the way I'm using PV?

I'm using PV to insert a buffer of size 50M between my video recording command and my video streaming command: /usr/bin/raspivid -b 8000000 -w 1280 -h 720 -rot 270 -v -fps 40 -o - -t 0 | pv -B 50M | ...
1
vote
0answers
68 views

How do I quit a piped less without quitting the source process?

I started a process that generates files but also has a lot of printed output. I started the process and piped it to less. The process should have completed a long time ago. I ls the directory where ...
1
vote
0answers
478 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 ...
1
vote
0answers
521 views

Pipe viewer (PV) not working?

I'm trying to use Pipe Viewer on a video pipe that I'm both writing and reading from. The below command works perfectly when I pass temp_video.h264 as an -i input to ffmpeg. However, when I attempt ...
1
vote
0answers
683 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 ...
1
vote
1answer
357 views

Weird results of triple piping to STDOUT & tee /dev/null >(wc -l > tmp.txt) & piping again embedding `cat tmp.txt`

$ seq 1 12773 | tee /dev/null >(wc -l > tmp.txt) | head -$((0x`openssl rand -hex 7` % `cat tmp.txt` + 1))|tail -1 --> 8473 (random between 1~12773) $ cat tmp.txt --> 8473 $ seq 1 12774 | tee ...
1
vote
1answer
161 views

Pipe data onto another machine with nologin

I have a huge directory I want to copy to another machine as a .tar.gz file. I don't have a lot of space on either machine, so I'd like to copy the file through a pipe, like this: tar -czf - ...
1
vote
0answers
554 views

mapfile and redirection issue

I would like to redirect the output of a command to input of mapfile. I'm doing this and it's working: xls2csv -x $files -W -q | sed '/^$/d' | grep -v '^The' > lista.txt mapfile -t titulos < ...
1
vote
0answers
700 views

strace for troubleshooting inter process communication

I have output captured by following command: strace -f -e trace=process,socketpair,open,close,dup,dup2,read,write -o rsync.log rsync -avcz --progress src/ dst/ it is a bit long so I've uploaded it ...