Standard error is another output stream typically used by programs to output error messages or diagnostics.
Questions tagged [stderr]
234 questions
107
votes
5 answers
Do progress reports/logging information belong on stderr or stdout?
Is there an official POSIX, GNU, or other guideline on where progress reports and logging information (things like "Doing foo; foo done") should be printed? Personally, I tend to write them to stderr so I can redirect stdout and get only the…
terdon
- 234,489
- 66
- 447
- 667
85
votes
2 answers
suppress stderr messages in a bash script
Consider the following (slightly silly) script name 'test1.sh':
#/bin/bash
#
sleep 10 &
echo sleep pid = $!
pkill sleep
When I run it, I get not only the output of the echo, but bash's reporting of the death of sleep on stderr:
$ ./test1.sh
sleep…
fearless_fool
- 1,015
- 1
- 7
- 10
85
votes
6 answers
Can I configure my shell to print STDERR and STDOUT in different colors?
I want to set my terminal up so stderr is printed in a different color than stdout; maybe red. This would make it easier to tell the two apart.
Is there a way to configure this in .bashrc? If not, is this even possible?
Note: This question was…
Naftuli Kay
- 38,686
- 85
- 220
- 311
46
votes
4 answers
X applications warn "Couldn't connect to accessibility bus:" on stderr
It seems like every application from the terminal gives warnings and error messages, even though it appears to run fine.
Emacs:
** (emacs:5004): WARNING **: Couldn't connect to accessibility bus:
Failed to connect to socket /tmp/dbus-xxfluS2Izg:…
vosov
- 563
- 1
- 4
- 4
34
votes
5 answers
How to redirect stdout to a file, and stdout+stderr to another one?
How can I achieve
cmd >> file1 2>&1 1>>file2
That is, the stdout and stderr should redirect to one file (file1) and only stdout (file2) should redirect to another (both in append mode)?
Swarna Gowri
- 525
- 4
- 9
31
votes
1 answer
How can I pipe only stderr in zsh?
In bash:
$ echo hi 2>&1 1>/dev/null | cat
$
While in zsh:
$ echo hi 2>&1 1>/dev/null | cat
hi
$
Is there a way to pipe only standard error while redirecting standard out?
Tavian Barnes
- 851
- 1
- 6
- 14
30
votes
3 answers
nohup: ignoring input and redirecting stderr to stdout
I am starting my application in the background using nohup as mentioned below -
root@phx5qa01c:/bezook# nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --fsconfigdir /opt/exhibitor/conf --hostname…
arsenal
- 3,053
- 17
- 44
- 49
27
votes
3 answers
Is it safe to redirect stdout and stderr to the same file without file descriptor copies?
I start off in empty directory.
$ touch aFile
$ ls
aFile
Then I ls two arguments, one of which isn't in this directory. I redirect both output streams to a file named output. I use >> in order to avoid writing simultaneously.
$ ls aFile not_exist…
exit_status
- 327
- 4
- 10
25
votes
4 answers
Copy stdout and stderr to a log file and leave them on the console within the script itself
Using bash, how do I copy stderr and stdout to a log file and also leave them displayed on the console?
I would like to do this within the script itself using an exec.
I tried with
exec &>> log.out
echo "This is stdout"
echo "This is stderr"…
adarshr
- 351
- 1
- 3
- 5
25
votes
3 answers
Does `Segmentation fault` message come under STDERR?
I ran an executable in bash
./code > log
It shows occasional error messages on terminal whereas all printf statements go into log file. I re-run it like below
./code >& log
Now, the occasional error messages also go into log. But if there is a…
user13107
- 5,265
- 10
- 45
- 62
22
votes
2 answers
What prevents stdout/stderr from interleaving?
Say I run some processes:
#!/usr/bin/env bash
foo &
bar &
baz &
wait;
I run the above script like so:
foobarbaz | cat
as far as I can tell, when any of the processes write to stdout/stderr, their output never interleaves - each line of stdio…
Alexander Mills
- 9,330
- 19
- 95
- 180
20
votes
1 answer
Output of command not in stderr nor stdout
I've stumbled on this issue, so I'm wondering how is this possible?
Standard run of command:
# zabbix_sender -c zabbix_agentd.conf -k mmysql.QCInserts -o 14
info from server: "Processed 0 Failed 1 Total 1 Seconds spent 0.000017"
sent: 1; skipped: 0;…
Jakov Sosic
- 368
- 2
- 8
18
votes
2 answers
Unix systems without /dev/stdin, /dev/stdout, and /dev/stderr?
An answer I gave to a question, and the comments to it, had me read the POSIX Conformance section of the Base Definitions to figure out whether /dev/stdin, /dev/stdout and /dev/stderr were actually needed for conformance to the POSIX standard.
It…
Kusalananda
- 320,670
- 36
- 633
- 936
17
votes
1 answer
POSIX compliant way to redirect stdout and stderr to a file
I am trying to write a script which is POSIX compliant, so it can run on any *nix system (Debian, Fedora, CentOS, AIX, Arch... ALL of them). When it comes to redirection, I am rather confused on what is supported by POSIX and what is not.
If I…
ExecutionByFork
- 447
- 3
- 8
16
votes
3 answers
When to use redirection to stderr in shell scripts
I know that well-behaved utilities like grep output "normal" messages to stdout, and error messages to stderr.
$ grep '^foo' file1 file2
file1:foo
grep: file2: No such file or directory
When I'm writing shell scripts myself I often find it hard to…
glts
- 572
- 1
- 4
- 12