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
4answers
75 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
40 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
58 views

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

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
161 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
18 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
53 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
71 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
17 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
89 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
55 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 ...
0
votes
0answers
23 views

Why I get the output of stderr printed in terminal instead of a file when I redirect the stdout into stderr? [duplicate]

When I run a command with output redirection into stdin like that: sudo -u postgres psql mydb -e -f ./my_psql.sql 2>&1 > output_log.log The error messages are being displayed into the ...
1
vote
1answer
30 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 ...
-1
votes
1answer
62 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
46 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
128 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
31 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
2answers
2k 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
161 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
118 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 ...
33
votes
5answers
4k 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
265 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
111 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
256 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
295 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 ...
1
vote
1answer
921 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
73 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 ...
0
votes
1answer
417 views

How can I store output in bash variable and suppress output to stderr and stdout? [duplicate]

If i'm doing oidvalue=$(snmpget -v 2c -c public localhost 1234) This will store the output of that command in oidvalue, however as it is now, it will print some error to the screen. How can I ...
4
votes
2answers
2k views

Why can't I get pgrep output right to variable on bash script?

I'm trying to make a script to either quit compton if it's running or start it if it's not running. I've read from man that it should exit 1 if process is found, so I've tried to make a script that ...
0
votes
2answers
362 views

Append string on redirect

When redirecting all output to stderr: stat file >&2 ... if the command throws an error (e.g. file does not exist) how can one prepend some arbitrary text, such as: <<MY ARBITRARY TEXT&...
1
vote
2answers
57 views

Redirect specific error in stderr

So I want to use an if statement to run a script to import some functions. $ cat functions.sh #!/bin/bash sampleFunction(){ if [[ ! "${fakeVariable}" == '2' ]] then read -n1 -r -p "...
0
votes
1answer
205 views

Confusion about stdout and stderr on the start-up terminal

I have an embedded Linux system with different programs running from start-up. Some of these programs write to stdout and stderr with printf(). When I first log into the system via SSH, I can see all ...
0
votes
2answers
1k views

Nohup: Redirect stderr to file and dismiss stdout

Per default, nohup writes stdout to nohup.out and dismisses stderr. I would like to have it the other way around: write stderr to a file and dismiss stdout.
0
votes
0answers
38 views

How do I know that the output is stderr? [duplicate]

When writing a very simple command in my terminal, like find ./ -name "pattern" I get a lot of 'errors' because I am not searching as sudo, and as consequence I get a lot of 'Permission denied' ...
-1
votes
1answer
155 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
142 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
105 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
1answer
310 views

Is data streamed as stdout/stderr removed after it appears in the terminal? [closed]

I know that stdout/stderr are a streams of data (uncommonly called "sources of data"), and that these streams of data also typically appear as terminal output. After the stdout/stderr data appears in ...
5
votes
3answers
551 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 ...
14
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
468 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/...
4
votes
4answers
4k 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
646 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
257 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
833 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
349 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
113 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
118 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
941 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
438 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 ...