In a script in perl I have the following:
print STDERR "Access error"
I would like know where this message is printed, but I don't know how can I see the Standar error output in LInux.
Both the standard (STDOUT
) and the error output (STDERR
) are displayed on your (pseudo) terminal.
If you want to trace the outputs :
error log :
./script.pl 2> err.log
standard output log :
./script.pl > out.log
both STDERR
and STDOUT
in the same file :
./script.pl > out.log 2>&1
or with bash :
./script.pl &> out.log
A good tutorial
It is printed to wherever standard error is set to for your environment.
If you are running it from a console, then it will be mixed in with the standard output and displayed on the console (it won't be redirected if you redirect STDOUT, you have to redirect it separately).
If you are running it from CGI under Apache, then it will be dropped into your error.log file (wherever Apache is configured to save that).
If you are running it from somewhere else… well an exhaustive list is out of scope for Stackoverflow so you should try asking a more specific question ;)
Example of where it might be directed to at the console:
david@raston err $ cat err.pl
#!/usr/bin/env perl
use strict;
use warnings;
use v5.16;
say "out";
say STDERR "error";
~/tmp/err :
david@raston err $ ./err.pl
out
error
~/tmp/err :
david@raston err $ ./err.pl > stdout
error
~/tmp/err :
david@raston err $ ./err.pl 2> stderr
out
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With