Questions tagged [stderr]

Standard error is another output stream typically used by programs to output error messages or diagnostics.

Filter by
Sorted by
Tagged with
-1
votes
1answer
221 views

Gzip verbosity goes to standard error

When I want to redirect any verbose output I usually do the following, [arif@arif test]$ rsync -v /home/arif/storage . 1> stdout [arif@arif test]$ cat stdout storage sent 177 bytes received 35 ...
0
votes
2answers
193 views

STDOUT + STDERR output … is there any difference between considering the output to be an empty string vs NULL

I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). ...
2
votes
2answers
117 views

Bash: turn stderr back on after suppressing

I've made this script which automates installing/uninstalling git. In my function for testing if git is installed, I use the git --version command and test the return code. I dislike the stderr ...
5
votes
3answers
606 views

How can I use sed to edit bash debug output? (bash -x)

#!/bin/bash -x echo This is a script that has debugging turned on This script outputs + echo This is a script that has debugging turned on This is a script that has debugging turned on I want to ...
17
votes
2answers
2k views

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/...
3
votes
3answers
636 views

Why can't `paste` print stdin next to stderr?

Usually paste prints two named (or equivalent) files in adjacent columns like this: paste <(printf '%s\n' a b) <(seq 2) Output: a 1 b 2 But when the two files are /dev/stdin and /dev/...
5
votes
4answers
5k views

How to redirect stderr in a variable but keep stdout in the console [duplicate]

My goal is to call a command, get stderr in a variable, but keep stdout (and only stdout) on the screen. Yep, that's the opposite of what most people do :) For the moment, the best I have is : #!/...
2
votes
1answer
838 views

What is non-standard input/output/error

I have read books/tutorials which mention standard input/output/error. My understanding is that: standard input/output/error are concepts of a process (i.e. if someone mentions standard input/output/...
0
votes
2answers
382 views

Remove lines from stderr [duplicate]

There is custom message that comes each time I ssh or scp which I would like to hide. I still want the rest of the stderr to go to stderr output. For example: a.sh contain one line: ssh example.com "...
4
votes
2answers
1k views

How to suppress stdout / stderr from a shell script output?

I have a script that is suppose to stop and recover the process to run in the background: process_id=`ps -eaf | grep -i daemon | grep -v grep | grep -v status | grep -v stop | awk '{print $2}'` (kill ...
4
votes
1answer
451 views

How to see from which file descriptor output is coming?

How to see from which file descriptor output is coming? $ echo hello hello $ echo hello 1>&2 hello all are going to /dev/pts/0 but there are 3 file descriptors 0,1,2
2
votes
2answers
140 views

Stderr redirection unexpectedly redirects some BASH built-ins as well

I'm trying to hide all the stderr from users running an interactive BASH script but keep the errors in a log file. However, simple stderr redirection quite unexpectedly hides some BASH output as well ...
2
votes
2answers
147 views

What were the original reason(s) for adding a “standard error” which is separate from “standard output”?

Unix provides standard output and standard error, which can be redirected independently. $ ls /not-exist ls: cannot access '/not-exist': No such file or directory $ ls /not-exist > redirect.out ...
12
votes
2answers
1k views

How (and why) use stderr for both reading and writing?

According to this answer by schily, less reads navigation commands from stderr if it's not able to open /dev/tty. This seems puzzling, since I've never seen anything write to another program's stderr ...
1
vote
1answer
528 views

Print and log stdout and stderr in fish shell

I am using the fish shell and try to log stdout and stderr into two separate files and printing them in the terminal at the same time (e.g., by piping each stream to tee). In bash I would do (see ...
4
votes
2answers
10k views

Execute command and store everything to variable in bash

In bash script I'm developing I'm trying to execute command and capture in variable(s): stdout stderr status code how to achieve that? The command is tar, if it is of any significance. I tried the ...
5
votes
1answer
12k views

what is the difference between >&2 and &>2 [duplicate]

Just wondering if there is any difference between: echo "running the npm patch" >&2; and echo "running the npm patch" &>2; I have actually never really understand that syntax.
0
votes
1answer
585 views

Append stderr and stdout to file

I have this: npm install "$tgz_path" &>> "$HOME/.r2g/logs/r2g.log"; but that is syntactically incorrect. How do I append stdout+stderr to that log file?
0
votes
1answer
74 views

stderr is being sent down pipeline but I don't want that

I have this: echo "$some_command" | bash 2> >(prepend 'r2g-stderr:' 'red') | prepend 'r2g-stdout:' 'yellow'; What I am trying to do: r2g-stderr: this is some stderr r2g-stderr: this is ...
1
vote
1answer
71 views

Send stderr to a different receiver in pipe

Right now I have this: echo "$run_test" | bash 2>&1 | prepend "r2g-test:" "yellow"; What this does is prepend "r2g-test:" to each line of the stdout/stderr. Because I am sending stderr to ...
0
votes
1answer
74 views

SysRq output into |less, |more, |tee?

If I issue a SysRq command, how do I redirect that output (whether it is stdout or stderr is documented nowhere) to |less, |more or |tee?
6
votes
3answers
5k views

Redirect STDERR and STDOUT to different variables without temporary files

func() { echo 'hello' echo 'This is an error' >&2 } a=$(func) b=??? I'd like to redirect the stderr to b variable without creating a temporary file. echo $b # output should be: "...
2
votes
2answers
73 views

stderr redirection by reading a file [duplicate]

I read content of the file into variable like this var=$(<somefile) But if the file doesn't exist I get accordingly an error message bash: somefile: No such file or directory Is it possible to ...
0
votes
0answers
74 views

In cron, /usr/bin/paplay does not display stderr

My PC's pulse audio dies whenever I open and close virtualbox windows in a certain situation. So I tried to monitor the audio state by crontab -e. Usually, in the commandline, $ paplay beep.wav &...
0
votes
1answer
363 views

Redirect command error to variable in if statement

I'm creating a script and I would need to redirect the error of a command inside an if statement. ERROR="" if tar -xf $1 -C $2/$DIR_NAME 2> $ERROR; then echo "Done" else rm -rf $2/$...
2
votes
1answer
349 views

How to capture stderr of a bash keyword (e.g. time)?

I want to time reading bash history and put the result into a variable. Unfortunately, time (which is a shell keyword) prints the result to stderr, and apparently redirecting stderr from shell ...
2
votes
4answers
393 views

How to make bash substitution $(<“filename”) silent

I want to replace cat: var=$(cat "filename" 2>/dev/null) by bashism syntax: var=$(<"filename") The problem is that I don't know how to make the bashism silent to avoid such warnings: bash: ...
0
votes
2answers
74 views

Supress specific output lines of a command

I wanted to search all the files starting with chrom in /var directory. So I executed this $ ls -R | grep "^chrom" To my astonishment, It showed this. Few starting lines look like this : amit@...
0
votes
2answers
266 views

How would I redirect an error from a failed if condition [closed]

I am trying to better understand STDERR and when/where to place 2> within the initial testing phase of a loop. My script is as follows... #!/bin/bash file1=/tmp/file1 file2=/tmp/file2 if [ -e $...
2
votes
2answers
17k views

Ambiguous output redirect

I'm trying to redirect stderr to stdout and then out to a file in an init script, but when I introduce stderr to stdout I get the “Ambiguous output redirect” error. Stdout alone does not result in the ...
9
votes
1answer
1k views

display STDOUTs before STDERR?

I'm new to bash and I can not for the life of me figure out how to run a certain command, suppose ./fff and print regular stdouts before stderr (I'm confused about the meaning myself) for example $ ...
1
vote
3answers
2k views

How can I convert to uppercase stderr output but not stdout?

I'm using rsync to backup some files: rsync -PaSh --stats --delete -e "-i key -p XXXX" "/source/" username@192.168.0.1:/destination/ 2> output.txt | grep -e 'bytes received' -e 'total bytes' -e ...
2
votes
3answers
704 views

Display console output 1 or more lines below

When I run a command like tail ~/SOMEFILE I get, for example: testenv@vps_1:~# tail ~/SOMEFILE This is the content of SOMEFILE. But what if I want to have a carriage return between: testenv@...
1
vote
2answers
2k views

Redirect stdout and/or stderr to path in variable

How do I redirect stdout and/or stderr to a path I have specified in a variable? Note: I don't want to overwrite the variable itself, I want to make std[xxx] write to the file specified in the ...
6
votes
3answers
3k views

Communicate backwards in a pipe

I have a simple pipeline: node foo.js | node bar.js bar.js will read from stdin to get data from foo.js. But what I want to do is ensure that bar.js gets one of the last messages from foo.js before ...
2
votes
1answer
244 views

Where does stderr go to during boot (SysVinit)?

I'm trying to diagnose some boot problems I am having with a custom linux kernel that I have configured and built. I've been digging through some of the source code for klogd, and apparently, if ...
6
votes
1answer
2k views

/dev/stderr in systemd service

I'm writing a service which should start LTE connection. But the utility I'm using to connect (sakis3g) is writing to /dev/stderr, which is not available in systemd and the log is full of Cannot ...
0
votes
2answers
1k views

Send stderr to stdout for purposes of grep [duplicate]

This won't work, because all the stdio will go to stderr: webpack -w --ignore=*.js | grep ignore so I try this: webpack -w --ignore=*.js > grep ignore 2>&1 but that will write a file ...
0
votes
1answer
83 views

Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?

Why do colors not show up (control characters) when piping stdout/stderr on *nix systems? When I do: foo | bar if foo writes color encoded strings (with control chars) to stdout, they won't show up ...
1
vote
2answers
56 views

Logging only a specific part of stderr?

Couldn't find anything on this, but I'm trying to only log a specific part of stderr to a file. So for example Running tar -xzf file 2>> log.txt, and getting an error tar: Child returned ...
0
votes
3answers
105 views

Script error message in a single line

I am executing the command mv /prod/new/outputlog/error.log /prod/hist/new/outputlog/error.log.32423423424 using shell script. Since the error.log file is not available the command writing an ...
5
votes
2answers
3k views

Is there a simple test for anything printed on stderr in shell/Bash?

I'd like invoke a command inside a shell script for Continuous Integration purposes. Exit status 0 means succes, otherwise failure. I'm writing a wrapper script to run several commands and fail if any ...
0
votes
1answer
4k views

ffmpeg command >> out.log 2>>error.log

I'm running: ffmpeg -i rtmp://localhost/test -crf 20 -t 00:10:00 ./video/hq/1503411993750.mp4 >> out.log 2>>error.log And expecting >> out.log 2>>error.log to result in ...
1
vote
2answers
520 views

Is there a process which doesn't send EOF before terminating and how to create it?

I suspect a process not to send EOF when killed with SIGINT and SIGKILL respectively. Can that be the case (or do all processes always send EOF to stdout and stderr after being terminated with ...
1
vote
1answer
485 views

How do I both output stdout and stderr and write them into a file? [duplicate]

I basically want to write my ping statistics into a file. So far, I accomplished this with ping adress | awk '{ print strftime("[%d.%m.%Y %H:%M:%S]"), $0}' > textfile but it would be more handy to ...
0
votes
1answer
792 views

List files and ignore permissions errors

I need to make a list of files bigger than 10G that will be the ignorefile input for a duply backup. However, I have some files which I don't have permissions to read. I want to ignore those that will ...
7
votes
2answers
942 views

Why does bash interactive shell by default write its prompt and echoes its interactive input to stderr?

I just noticed that bash interactive shell by default writes the prompt and echoes anything you type to file descriptor 2 (stderr). This can be verified by running bash inside strace. What is the ...
1
vote
2answers
812 views

Capture stdout and stderr as separate variables in fish shell

Is this even possible? I'd like to run a command but capture its stdout and stderr as separate variables. Currently I'm using set -l var (cmd), which leaves stderr untouched. I can do set -l var (cmd ...
1
vote
1answer
697 views

How do I use gpsdecode to output the results of gpscat in a readable manner?

I am connected to a processor with GPS attached through a USB-serial port. What I've been trying to do is read the GPS data by doing: gpscat /dev/ttyS2 | gpsdecode However, it's very slow and after ...
0
votes
2answers
825 views

Why is /dev/stderr invalid when redirecting to a pipe in cygwin?

I recently stumbled over a surprising issue with an invalid /dev/stderr on an up-to-date cygwin which is also present on a well-matured Debian installation. (Edit: Opposed to what I originally thought,...