pipe

How to pipe a string to process' STDIN?

你说的曾经没有我的故事 提交于 2019-12-23 18:24:23
问题 I have a command that expects input from a pipe. For example, consider the famous cat command: $ echo Hello | cat Hello Suppose I have a string in a Perl 6 program that I want to pipe to the command: use v6; my $input = 'Hello'; # This is the string I want to pipe to the command. my $proc = run 'cat', :in($input); This does not work (I get no output). I can work around the problem by invoking bash and echo : my $proc = run 'bash', '-c', "echo $input | cat"; But is there a way I can do this

Do I need to flush named pipes?

▼魔方 西西 提交于 2019-12-23 18:17:43
问题 I cannot find whether named pipes are buffered, hence the question. The manpage says https://linux.die.net/man/3/mkfifo: A FIFO special file is similar to a pipe ... any process can open it for reading or writing, in the same way as an ordinary file. Pipes are not buffered, no need to flush. But in a ordinary file, I would fflush (or fsync) the file descriptor. How about named pipe? 回答1: Pipes are not buffered, no need to flush. I'd actually put that the other way around: for most intents and

Reading child process' output as soon as some is available?

核能气质少年 提交于 2019-12-23 18:14:55
问题 I've been trying various methods (popen, pipes + fork/exec, ...) to read a child process' output, all of which are working, but exhibit the same behavior: whenever I try to read the output using read / fread , it only returns when the buffer is completely full, or when the child exits. I'm looking for a behavior that's more like that of sockets: reading any amount of data as soon as some is available. How do I do that? 回答1: Generally you don't. In particular, the child process will buffer the

Pass binary data between python processes

陌路散爱 提交于 2019-12-23 13:07:39
问题 I need to transfer binary data between python processes on linux efficiently. However I can't find a way to pass it with pipe. The closest I got was to pass it as string but it keeps its binary form for some reason so it causes me problems. ciphertext, tag = cipher1.encrypt_and_digest(input().encode()) print(ciphertext) ciphertext is binary but when I test its type at the other process print(type(sys.stdin.read())) I get <class 'str'> Any ideas? 回答1: In Python 3 you can't use print or input

Angular 2: Set and remove custom pipes?

我与影子孤独终老i 提交于 2019-12-23 12:17:18
问题 I've created three custom pipe to order data from server (ASC, DESC and Default), they work perfectly, I want that this three pipes active or not depending of the interaction of the user. The question is, It's posible change the custom pipe with a variable for example?. This is my code... <label *ngFor="let user of users | {{pipeOrderType}}:'name'">{{user.id}}{{user.name}}, </label> 回答1: There is no way to assign different pipes dynamically. You can create a pipe that behaves differently

how shell pipe handles infinite loop

∥☆過路亽.° 提交于 2019-12-23 12:09:21
问题 Whenever I need to limit shell command output, I use less to paginate the results: cat file_with_long_content | less which works fine and dandy, but what I'm curious about is, less still works even if the output is never ending, consider having the following script in inf.sh file: while true; do date; done then I run sh inf.sh | less And it's still able to again paginate the results, so is it correct to say that pipe streams the result rather than waiting for the command to finish before

can't read from stream until child exits?

谁说我不能喝 提交于 2019-12-23 10:55:16
问题 OK I have a program that creates two pipes -> forks -> the child's stdin and stdout are redirected to one end of each pipe -> the parent is connected to the other ends of the pipes and tries to read the stream associated with the child's output and print it to the screen (and I will also make it write to the input of the child eventually). The problem is, when the parent tries to fgets the child's output stream, it just stalls and waits until the child dies to fgets and then print the output.

Maintaining a FIFO readable across different executions

巧了我就是萌 提交于 2019-12-23 10:27:13
问题 I've never used a named pipe before and recently realized that is just what I need. I'm running a program using gnu parallel which could produce tons (GB's to 1TB, hard to know right now) of output formatted for a data base on mySQL. I figured out that I can open two terminals: Terminal 1 gets something like: find . -type f -name "*.h" | parallel --jobs 12 'cprogram {}' > /home/pipe Where pipe is a fifo made with mkfifo . On a second terminal, I run a command similar to this: mysql

WCF with named pipe under different user sessions

柔情痞子 提交于 2019-12-23 10:19:34
问题 I have an application that can be active simultaneously under different user sessions on the same box. It consists of a client and a server, both running under the interactive user and communicating via WCF over named pipes. If I create a WCF server listening on, say, "net.pipe://localhost/MyService" ... two instances of the server process cannot exist under the same user session, but WCF allows two servers using this same base address under the different user sessions. Here are my questions;

OpenCV Python, reading video from named pipe

限于喜欢 提交于 2019-12-23 10:10:42
问题 I am trying to achieve results as shown on the video (Method 3 using netcat) https://www.youtube.com/watch?v=sYGdge3T30o The point is to stream video from raspberry pi to ubuntu PC and process it using openCV and python. I use command raspivid -vf -n -w 640 -h 480 -o - -t 0 -b 2000000 | nc 192.168.0.20 5777 to stream the video to my PC and then on the PC I created name pipe 'fifo' and redirected the output nc -l -p 5777 -v > fifo then i am trying to read the pipe and display the result in the