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
vote
1answer
36 views

How to check if command had any output (zsh)

I want to print a new line after a command if it had any output (I hope that this will make it more readable once my terminal starts scrolling). I found this: precmd() { precmd() { print &...
0
votes
0answers
41 views

Where does stdout and stderr go in the background

When processes get executed in the background, for example by using systemd to start the processes at startup, why doesn't the stdout and stderr still appear on the terminal when we access the ...
0
votes
0answers
34 views

separate stderrs of different pipe commands to different tmux/screen/ncurses/… windows?

I have a pipe which contains multiple commands which tend to write to stderr. Naturally, the output will be interleaved. I wonder if there is a utility that neatly separates the stderrs of the ...
0
votes
1answer
24 views

how to get split commands output to file

I want to print output of below command to file, can you help me I tried 2>&1 even 2>> also dd if=/dev/random bs=1 count=1000 status=progress |split -b 10 -a 10 I have other dd command ...
0
votes
1answer
21 views

Redirect systemd service STDERR to command (sendmail)

This seems like something that's been asked before but I can't find it anywhere. I have a systemd service that runs on a timer, updating my packages. I want to get emailed using ssmtp every time the ...
1
vote
0answers
24 views

How to get stderr separate from stdout in task-spooler jobs

I am trying to get a separate output file for stderr for jobs sent to task-spooler on Ubuntu 20.04. This command works fine: tsp -Lfetcher sh -c 'curl -v https://google.com' But I am having trouble ...
0
votes
2answers
104 views

redirect stdout and stderr to null in the middle of a chain of '&&'s

TL;DR I've researched this, and you can see what I've found in the More Details and My Attempts section. My command is date && echo "hi 1" && echo "1/0" | bc >/...
2
votes
1answer
69 views

Additional file descriptor for debugging and piped output (logging, metrics, etc)

For a bash script project, I write human-readable log info to stdout/stderr. Additionally, I want to write formatted metrics to a third stream that will be discarded by default but can be redirected ...
1
vote
1answer
68 views

Send debug output to terminal multiplexer

Given a shell script (bash in this example), one can use the set -x or -x passed to bash or other supporting shells to generate debug output. I know how to redirect said output to a file ./script.sh 2&...
1
vote
1answer
300 views

Separate stdout and stderr for `docker run`?

Can I get separate stdout and stderr pipes for docker run? Example: $ docker run --rm -it alpine sh -c 'echo this is stdout; echo this is stderr >&2' \ 2> stderr.txt this is stdout this is ...
-5
votes
2answers
152 views

Standard error to standard output - is there other options beside redirection?

I have very limited understanding about standard error and standard output... One of the common methods is to redirect standard error to standard output. Does it mean that error (which usually goes to ...
0
votes
1answer
605 views

Issue passing newline `\n` character to curl command

My Jenkins multiline parameter is read in a variable SERVER_IP which is passed to Unix curl command as below: The curl command triggers a webpage(Jenkins Build) and passes the parameters to the ...
0
votes
0answers
13 views

How can I suppress cupsfilter debug output?

I have a Ruby program that calls out to the cupsfilter executable on both Linux and Mac OS. On both OS's, there is a lot of debug output going to stderr. Here is an excerpt: DEBUG: argv[0]="...
0
votes
1answer
219 views

How to stop stderr output from gcloud command in cron script without stopping all error output?

I have a bash script for a cron job that uses Google Cloud SDK's gcloud command after some conditional statements. eg. gcloud compute firewall-rules update allow-ssh --source-ranges=$(echo "${...
1
vote
1answer
56 views

Redirect standard error during concatenate using cat

Need some help on redirecting error to stdout for the below command find /mypath/env/test/ -name "*.tmp" -exec cat '{}' ';' >> /mypath/env/final/merged.txt 2>&1 This command ...
1
vote
1answer
52 views

What does “export >/dev/stderr” mean?

I've found in a bash script following line: export >/dev/stderr what does it mean?
1
vote
2answers
307 views

Can a program output to STDERR and still return a zero exit status? [closed]

I'm working on refactoring some Python scripts intended to be run from the command line. The scripts use logging, which makes some messages being written to STDERR (among other things). I wonder if it'...
-1
votes
3answers
364 views

How does > /dev/null 2>&1 work? [duplicate]

I understand how redirecting output with > /dev/null causes it not to print to screen. But for some reason this is not always enough, and some things still do get printed. In those cases > /...
12
votes
1answer
2k views

POSIX compliant way to redirect stdout and stderr to a file [duplicate]

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 ...
2
votes
1answer
66 views

How do I debug why stderr is being suppressed?

Running some shell functions and ctrl-c-ing them leads to my stderr being suppressed, such that echo hi >&2 and echo hi > /dev/stderr print nothing. I want to debug this, but I have no idea ...
3
votes
1answer
387 views

How to redirect this “Floating point exception(core dumped)” error?

I want to redirect the output of a program to a file with variable name and, at the same time, redirect the possible error. This is the script so far: #!/bin/bash echo "Se ejecutará el PET-linux.x ...
1
vote
3answers
153 views

Which processes have standard file descriptors?

Which is the correct statement? Every Unix process has the standard file descriptors open: standard input, standard output and standard error. or Every Unix process attached to a terminal has ...
-1
votes
1answer
28 views

bash won't exit on error if a program's output is redirected to log file

#!/bin/bash exec 200>/var/lock/scraper || exit 1 flock -n 200 || exit 1 cd /home/ubuntu/web_scraper /home/ubuntu/.nvm/versions/node/v13.12.0/bin/node mongo/scraper.js > logs/scraper.log ...
0
votes
1answer
135 views

Terminal and Grepping Stderr: how do I run a verbose code and grep the standard error without changing anything else?

Suppose I have a code, and it is running in a very verbose mode. This maximum verbosity exposes a message that I'd like to read to see how everything is doing. However, the terminal is flooded with ...
1
vote
4answers
1k views

Reading from stderr in c

This is my c program read from stderr i write #include <uninstd.h> #include <stdio.h> int main(void) { char buff[3]; read(2, buff, sizeof(buff)); printf("%s", buff"); return 0; } My ...
1
vote
1answer
110 views

Is it possible to write an alias or function in Bash to filter out the errors (stderr)?

I sometimes would do grep -ri foo . but in some node_modules, it could have some links to places that don't exist. So I can do a grep -ri foo . 2>&- or grep -ri foo . 2> /dev/null but ...
1
vote
1answer
164 views

A program's output seems to be neither stdout nor stderr? [duplicate]

I got a program vsftpd which output doesn't seem to be either stdout or stderr (if that's even possible?) My terminal output is: ~# vsftpd 500 OOPS: SSL: cannot load RSA private key I tried to ...
2
votes
1answer
371 views

Stdout / stderr redirection doesn't work at preventing /dev/tcp/host/port redirection errors

This is normal redirection. user@linux:~$ randomcommand randomcommand: command not found user@linux:~$ 2> user@linux:~$ randomcommand 2> /dev/null user@linux:~$ &> user@linux:~$ ...
0
votes
0answers
70 views

Print clang include path and store in file

I'm writing a program that needs to pull in the clang include paths. Thanks to Dump include paths from g++ I'm half-way there. The command I'm using is: clang++ -E -x c++ - -v < /dev/null The ...
0
votes
1answer
118 views

Use 2>&1 to direct stdout/stderr for a single command only among many in a BASH script

My first post, please be kind :) I'm writing my first ever BASH script, and using systemd to invoke it on a timer (my first systemd units too!). The script runs backups daily, and uses notify-send to ...
2
votes
1answer
311 views

How to redirect stderr in busybox?

I have BusyBox v1.27.1 (2017-08-03 03:14:35 CEST) built-in shell (ash) on router. I found a weird issue: root@DD-WRT:/# echo -n "Hi" 2>/dev/null -sh: 2: Invalid argument Seems I cannot redirect ...
1
vote
1answer
42 views

mysqldump into file with any error firing off a cURL request with error information

I'm attempting to setup a backup that I want to execute from the command line where, in the case of an error, it curls the error to an API endpoint. Something like: mysqldump -u whatever -pwhatever ...
1
vote
2answers
94 views

Add own information to error stream

As is known, we can redirect errors to a specific file with: ./some_script 2>error_log I am running multiple scripts, and would like them to put their errors into a single error file. Is there ...
1
vote
0answers
61 views

How does redirecting stdout to stderr work [duplicate]

Just trying to redirect stout to stderr. But I'm a little confused about these two commands. echo test 2>/dev/null 1>&2 echo test 1>&2 2>/dev/null I don't understand why the ...
1
vote
1answer
34 views

Supressing specific error throws from a bash script [closed]

I am using a library that throws a reasonable error when called upen and completes the desired action such that my outputs are as expected. However, as other people will use the script, I think the ...
0
votes
1answer
216 views

curl still emitting progress info even with --silent option

I have this curl command: curl --silent -o- https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/install.sh | bash || { echo "Could not install run-tsc-if on your system."; exit 1; ...
0
votes
0answers
57 views

Script - Write stdout and stderr to a file AND to the terminal without pipe [duplicate]

I don't know if it's possible, I would like start a bash script without pipe which write everything to a file and at the same time see the output on the terminal. So I know how to do that with this ...
2
votes
3answers
208 views

How to capture stderr of function that modifies current environment?

The module function of the Environment Modules1 package does its work by modifying various environment variables of the current shell process. Unfortunately, this function returns 0 whether it ...
1
vote
2answers
34 views

Discard “access denied” stderr natively in find

Is there an option in find that allows me to suppress the error messages that I get from it trying to access directories for which I don't have access? I know I can just discard stderr, but it seems ...
0
votes
4answers
5k views

How to read stderr from the process running in the background?

I wanna send the daemon into the background and only continue my script execution when the daemon outputs the particular line to the stderr, something among the lines: # Fictional daemon { for x ...
2
votes
2answers
239 views

Openssh client is blocking forever if stderr is redirected to stdout

It seems there might be a problem in the openssh. In the bash shell if I redirect stderr to stdout it's blocking forever, so I have to KeyboardInterrupt: $ ssh -fTNF './config' -MS './sockd5/...
27
votes
3answers
2k views

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 ...
1
vote
0answers
193 views

Curl download speed restricted when down/uploading from stdin/stdout

I'm running 2 curl commands where one downloads all the data into stdout/in until the stack is filled and another uploading whatever is in it out but it seems like the speed is restricted. For the ...
34
votes
5answers
6k views

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 ...
4
votes
1answer
314 views

stdout and stderr redirection to different files

How can I redirect stdout to 2 different files and stderr to another, different file? I want something like <my_cmd> 1> file1 file2 2>file3 I know: <my_cmd> | tee file1 file2 > /...
2
votes
1answer
124 views

What is the most succinct way of terminating the rest of a pipeline if a command fails?

Consider the following: command1 | command2 | command3 As I understand pipelines every command is run regardless of any errors which may occur. When a command returns stderr, it is not piped to the ...
1
vote
1answer
395 views

Understanding File Streams and File Descriptors

For extra context, I asked this question earlier, and thought I understood things, but not anymore. I know that echo ignores stdin. I know that stdin, stderr and stdout exist and, in this context, I ...
0
votes
3answers
662 views

Handle specific error in bash

As a part of my script, I want to publish package to nuget feed: dotnet nuget push package.1.2.3.nupkg --source "mysource" --api-key "mykey" The command may print error: 409 already contains version ...
3
votes
1answer
2k views

What controls the buffering of stdout stderr?

What part of the system sets up the buffering of the three standard streams when a program is started? Is this part of linux, or glibc, or maybe bash? Does POSIX define the behaviour, or is it part ...
1
vote
0answers
108 views

Color rm -i prompt messages

I'm looking for a way to apply custom colors to messages emitted by the rm -i command: ~ $ rm -i file.txt rm: remove regular empty file 'file.txt'? I understand that I need to redirect the stderr as ...

1
2 3 4 5