piping

Piping error messages with grep

試著忘記壹切 提交于 2020-01-04 07:53:11
问题 I have a script that fails because some files are missing. Running the script and piping it to grep $ ./adder | grep Error produces the following output: Error in <TFile::ReadBuffer>: error reading all requested bytes from file v2.2_V3_194424_194712/output_853.root, got 0 of 300 Error in <TFile::Init>: v2.2_V3_194424_194712/output_853.root not a ROOT file and similar output with different files I'd like to extract the root files like v2.2_V3_194424_194712/output_853.root from this output, but

Why is piping output of subprocess so unreliable with Python?

穿精又带淫゛_ 提交于 2020-01-04 01:59:08
问题 (Windows) I wrote some Python code that calls the program SoX (subprocess module), which outputs the progress on STDERR, if you specify it to do so. I want to get the percentage status from the output. If I call it not from the Python script, it starts immediately and has a smooth progression till 100%. If I call it from the Python script, it lasts a few seconds till it starts and then it alternates between slow output and fast output. Although I read char by char sometimes there RUSHES out a

unsuccessful use of popen() in C?

坚强是说给别人听的谎言 提交于 2020-01-02 06:42:14
问题 I can run the following command xwd -root | xwdtopnm | pnmtojpeg > screen.jpg in a terminal under linux and it will produce a screenshot of my current screen. I try to do the following with the code: #include <stdio.h> #include <stdlib.h> int main() { FILE *fpipe; char *command="xwd -root | xwdtopnm | pnmtojpeg"; char line[256]; if ( !(fpipe = (FILE*)popen(command,"r")) ) { // If fpipe is NULL perror("Problems with pipe"); exit(1); } while ( fgets( line, sizeof line, fpipe)) { //printf("%s",

Pipe output of python script

蹲街弑〆低调 提交于 2020-01-02 05:15:14
问题 I'm running ./sample.py --url http://blah.com without error, though if I run ./sample.py --url http://blah.com | wc -l or similar I receive an error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u200f' in position 0: ordinal not in range(128) How do I make a python script compatible with my terminal commands? I keep seeing reference to sys.stdin.isatty though its use case appears to be opposite. 回答1: When Python detects that it is printing to a terminal, sys.stdout.encoding is

R - Running a t-test from piping operators

假如想象 提交于 2019-12-30 03:25:08
问题 Is it possible to run a t.test from piping operators? I tried to find the answer to this, but most of the questions around this topic look at doing many tests on the same dataset. I've looked a broom package, but it seems to be good for reading the results. What I'm interested in is whether it's possible to just use piping and run the t.test() on the output. For example, here is some sample data library(dplyr) d <- data.frame( group = sample(LETTERS[1:2], size = 10, replace = T), amount =

PHP email piping error

痞子三分冷 提交于 2019-12-24 23:50:28
问题 I'm writing a php script to pipe email from a forward in my CPanel. I have found this script on the internet; I am trying to parse the email and send it back to myself for testing, but it instead returns this error: The following text was generated during the delivery attempt: ------ pipe to |/home1/<account>/pipe.php generated by pipe@example.com ------ Error in argument 1, char 3: option not found < Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] php <file> [args...] -a Run interactively -b

R - tidyr - spread() - dealing with NA as column name

孤街醉人 提交于 2019-12-24 16:03:04
问题 I am spreading multiple categorical variables to Boolean columns using tidyr::spread() . As the data contains NAs, spread creates a new column without a name. What I'm looking for is a way to get rid off the NAs using a) a piping solution (I've tried select_() and '['() , but don't know how to refer to the NA column's name or index) or b) a custom function, which would be even better c) a way to simply not generate the NA columns, Hadleyverse compatible, if possible. Below is my current (and

PHP email Piping get 'to' field

拟墨画扇 提交于 2019-12-24 09:04:06
问题 I am trying to use email piping with PHP. I have it working except I can't get the 'To' field. I am using the following PHP code: #!/usr/bin/php -q <?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); $to1 = explode ("\nTo: ", $email); $to2 = explode ("\n", $to1[1]); $to = str_replace ('>', '', str_replace('<', '', $to2[0])); } fclose($fd); mail('email@example.com','From my email pipe!','"' . $to . '"'); ?> If I use a email

Pipe function not executing properly

自作多情 提交于 2019-12-24 07:17:39
问题 I have constructed the following program to try to pipe in my own shell. A StringArray is simply a char** I have constructed. The code runs fine, but when I put in cat txt.txt | grep a , nothing prints back to the screen. When debugging, I saw that the code seems to stop around like 152 (where the print-out command is), where pid==0 and i==0 . For context, I'm calling this function in another function after a pipe has been detected. void doPipe(StringArray sa) { printf("In 69\n"); int filedes

passing paremeters from PHP Email piping

跟風遠走 提交于 2019-12-23 01:12:38
问题 I have a PHP Script that received information from a piped email forwarder. Currently everything works perfectly. I just want to manipulate the received parameters to receive only the data I want from the email the script is: #!/usr/local/bin/php -q <?PHP //get email $fd = fopen("php://stdin", "r"); $email_content = ""; while (!feof($fd)) { $email_content .= fread($fd, 1024); } fclose($fd); //get email end //get variables from email start //split the string into array of strings, each of the