Questions tagged [stderr]

The standard error output stream (stderr) is typically used by a program to output error messages or diagnostics.

The standard error stream, stderr, is a stream typically used by a program to output error or diagnostic messages. It is one of the three standard streams used by a UNIX-like program, along with and .

Like , stderr is outputted to the text terminal unless redirected.

The file descriptor for standard output is 2 (two); the POSIX definition is STDERR_FILENO.

1405 questions
87
votes
8 answers

How to replicate tee behavior in Python when using subprocess?

I'm looking for a Python solution that will allow me to save the output of a command in a file without hiding it from the console. FYI: I'm asking about tee (as the Unix command line utility) and not the function with the same name from Python…
sorin
  • 161,544
  • 178
  • 535
  • 806
84
votes
5 answers

Gradle: How to get output from test STDERR/STDOUT into console?

(Gradle 3.2.1) I run some java tests, which logs output in Stderr/Stdout. I can see that output, if I start gradle test --info but in that case, much of unwanted output from 3-rd party libraries is there too. Documentation suggests using…
Alexei Vinogradov
  • 1,548
  • 3
  • 15
  • 34
75
votes
9 answers

Temporarily Redirect stdout/stderr

Is it possible to temporarily redirect stdout/stderr in Python (i.e. for the duration of a method)? Edit: The problem with the current solutions (which I at first remembered but then forgot) is that they don't redirect; rather, they just replace the…
user541686
  • 205,094
  • 128
  • 528
  • 886
74
votes
7 answers

How to capture stdout/stderr with googletest?

Is it possible to capture the stdout and stderr when using the googletest framework? For example, I would like to call a function that writes errors to the console (stderr). Now, when calling the function in the tests, I want to assert that no…
Jan Rüegg
  • 9,587
  • 8
  • 63
  • 105
73
votes
6 answers

PHP StdErr after Exec()

In PHP I am executing a command with exec(), and it returns if successful an URL; $url = exec('report'); However, I want to check stderr, if something went wrong. How would I read the stream? I want to use php://stderr, but I am not sure how to use…
martin
  • 949
  • 3
  • 11
  • 18
72
votes
6 answers

redirect stdout/stderr to a string

there has been many previous questions about redirecting stdout/stderr to a file. is there a way to redirect stdout/stderr to a string?
Prasanth Madhavan
  • 12,657
  • 15
  • 62
  • 94
70
votes
1 answer

Bash how do you capture stderr to a variable?

Bash how do you capture stderr to a variable? I would like to do something like this inside of my bash script sh -c path/myExcecutable-bin 2>&1 =MYVARIABLE How do you send stderror output to a variable ?
stackoverflow
  • 18,348
  • 50
  • 129
  • 196
69
votes
10 answers

How to debug "FastCGI sent in stderr: Primary script unknown while reading response header from upstream" and find the actual error message?

SO has many articles mentioning this error code: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream... That probably means that this error message is more or less useless. The message is telling us that…
101010
  • 14,866
  • 30
  • 95
  • 172
68
votes
4 answers

How to tee to stderr?

I want to split stdout so that it is printed both to stdout and stderr. This sounds like a job for tee but the syntax is evading me - ./script.sh | tee stderr Of course, how should stderr actually be referred to here?
djechlin
  • 59,258
  • 35
  • 162
  • 290
66
votes
4 answers

Bash script - store stderr in a variable

I'm writing a script to backup a database. I have the following line: mysqldump --user=$dbuser --password=$dbpswd \ --host=$host $mysqldb | gzip > $filename I want to assign the stderr to a variable, so that it will send an email to myself…
thornate
  • 4,902
  • 9
  • 39
  • 43
66
votes
6 answers

Capture both stdout and stderr in Bash

I know this syntax var=`myscript.sh` or var=$(myscript.sh) Will capture the result (stdout) of myscript.sh into var. I could redirect stderr into stdout if I wanted to capture both. How to save each of them to separate variables? My use case here…
djechlin
  • 59,258
  • 35
  • 162
  • 290
65
votes
5 answers

How do you print to stderr in R?

How do you print to stderr in R? This would especially useful for scripts written in Rscript.
Frank
  • 64,140
  • 93
  • 237
  • 324
63
votes
7 answers

Python read from subprocess stdout and stderr separately while preserving order

I have a python subprocess that I'm trying to read output and error streams from. Currently I have it working, but I'm only able to read from stderr after I've finished reading from stdout. Here's what it looks like: process =…
Leah Sapan
  • 3,621
  • 7
  • 33
  • 57
57
votes
8 answers

Should the command line "usage" be printed on stdout or stderr?

When printing the "usage" of an application, should it be done on stdout or on stderr? Depending on the application I've seen several cases, but there doesn't seem to be one rule. Maybe I'm mistaken and there is one good practice. In that case, what…
Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137
55
votes
3 answers

How do I write to standard error in PowerShell?

I'm having trouble figuring out how to both echo to the standard error stream and redirect the error stream of an executable. I have come from a Bourne shell and Korn shell background, of which I would use; # Write to stderr echo "Error Message!"…
Brett Ryan
  • 26,937
  • 30
  • 128
  • 163
1
2
3
93 94