pipe

Capturing stdout/stderr separately and simultaneously from child process results in wrong total order (libc/unix)

倖福魔咒の 提交于 2021-02-10 14:42:20
问题 I'm writing a library that should execute a program in a child process, capture the output, and make the output available in a line by line (string vector) way. There is one vector for STDOUT, one for STDERR, and one for "STDCOMBINED", i.e. all output in the order it was printed by the program. The child process is connected via two pipes to a parent process. One pipe for STDOUT and one for STDERR. In the parent process I read from the read-ends of the pipes, in the child process I dup2() 'ed

Angular ngFor ngIF condition in data filtering by pipe

倖福魔咒の 提交于 2021-02-10 07:32:33
问题 ngFor filtering based on a search using pipe - This is working fine , Now I have to add ngIf condition based on the search query If nothing result then I have to show another new div with 'no data' text <input type="text" [(ngModel)]="queryString" placeholder="Search to type"> <li *ngFor="let project of projects | FilterPipe: queryString ;> {{project.project_name}} </li> //pipe transform(value: any, input:any ): any { if(input){ input = input.toLowerCase(); return value.filter(function (el:

Angular ngFor ngIF condition in data filtering by pipe

坚强是说给别人听的谎言 提交于 2021-02-10 07:31:40
问题 ngFor filtering based on a search using pipe - This is working fine , Now I have to add ngIf condition based on the search query If nothing result then I have to show another new div with 'no data' text <input type="text" [(ngModel)]="queryString" placeholder="Search to type"> <li *ngFor="let project of projects | FilterPipe: queryString ;> {{project.project_name}} </li> //pipe transform(value: any, input:any ): any { if(input){ input = input.toLowerCase(); return value.filter(function (el:

use of pipe operator “%>%” using :: in R

£可爱£侵袭症+ 提交于 2021-02-10 07:06:30
问题 I am building an R package and I am using intensively the pipe operator %>%. I am wandering how to call it from purrr package using :: operator. I have tried purrr::%>% but get an error. I appreciate any guide on this. P.D: should I call the pipe operator from magrittr rather than purrr? 回答1: Your best approach is to import it from magrittr and re-export it if you want your users to be able to access it. Using it internally to your package only, this may work: `%>%` <- purrr::`%>%` check:

Print pv output (stderr) to file

和自甴很熟 提交于 2021-02-10 05:33:09
问题 How can I print the stderr output of pv to a file? For example: timeout 5s dd if=/dev/random | pv -r > /dev/null [ 505kiB/s] The rate line output is "updated" over the course of my five second timeout. I tried this but it does not work (log is empty): timeout 5s dd if=/dev/random | pv -r > /dev/null 2> rates.log I believe it has something to do with carriage returns in the stderr output, but after an hour I am stuck. Ideally my log file would have multiple lines each time pv prints a new

Node.js Streaming/Piping Error Handling (Change Response Status on Error)

巧了我就是萌 提交于 2021-02-08 19:57:46
问题 I have millions of rows in my Cassandra db that I want to stream to the client in a zip file (don't want a potentially huge zip file in memory). I am using the stream() function from the Cassandra-Node driver, piping to a Transformer which extracts the one field from each row that I care about and appends a newline, and pipes to archive which pipes to the Express Response object. This seems to work fine but I can't figure out how to properly handle errors during streaming. I have to set the

Using grep from python console

流过昼夜 提交于 2021-02-08 08:59:26
问题 Using python how can I make this happen? python_shell$> print myPhone.print_call_log() | grep 555 The only thing close that I've seen is using "ipython console", assigning output to a variable, and then using a .grep() function on that variable. This is not really what I'm after. I want pipes and grepping on anything in the output (including errors/info). 回答1: Python's interactive REPL doesn't have grep , nor process pipelines, since it's not a Unix shell. You need to work with Python objects

Using grep from python console

给你一囗甜甜゛ 提交于 2021-02-08 08:59:17
问题 Using python how can I make this happen? python_shell$> print myPhone.print_call_log() | grep 555 The only thing close that I've seen is using "ipython console", assigning output to a variable, and then using a .grep() function on that variable. This is not really what I'm after. I want pipes and grepping on anything in the output (including errors/info). 回答1: Python's interactive REPL doesn't have grep , nor process pipelines, since it's not a Unix shell. You need to work with Python objects

Conditional pipelining in Bash

为君一笑 提交于 2021-02-07 18:12:41
问题 I have a filter that I want to enable optionally and I wonder how can I do this in bash in a clean way. FILTER="| sort" # also can be empty ls $FILTER | cat This code does not work because it will call ls with | and sort as parameters. How can I do this correctly? Please mind that I am trying to avoid creating if blocks in order to keep the code easy to maintain (my piping chain is considerable more complex than this example) 回答1: What you have in mind doesn't work because the variable

How to automatically hit Enter in bash script when asked?

妖精的绣舞 提交于 2021-02-07 14:50:31
问题 I know that this question is answered many times, but I still can't figure out how to do it. Maybe it's because I don't know the correct keyword to search for. Using echo -ne '\n' | enter doesn't work. My code is: #! /bin/bash #Grub-customizer sudo add-apt-repository ppa:danielrichter2007/grub-customizer echo -ne '\n' | return sudo apt-get update sudo apt-get install grub-customizer 回答1: You're supposed to pipe the \n into the command that's going to be receiving it (otherwise it won't ever