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
0 votes
0 answers
27 views

Questions on shell redirection [duplicate]

I am studying for my RHCSA and already have my Linux+ and I'm trying to better understand shell redirection beyond just understanding the basic use cases and I am trying to grasp it at a deeper ...
user avatar
  • 9
0 votes
0 answers
34 views

Exporting Python's script errors/traceback to file with netcat

I have a Python script accessible with netcat: nc 'serverIP' port. The Python script awaits an input from the user. If the input is expected, the script keeps running. If the input is unexpect (e.g. ...
user avatar
0 votes
0 answers
51 views

Xauthority file does not exist - so what?

I run X11 programs on a Linux host, displaying remotely on a Mac running the XQuartz X11 server. First of all, this is all on my private LAN so I don't need to tunnel the X connection through SSH, and ...
user avatar
0 votes
1 answer
34 views

linux contextually process stderr only if present

I want to only have a process called if there actually is a STDERR present, but I don't know how to evaluate if one is actually present or not. This code: errtest() { kubectl get namespace -A ...
user avatar
0 votes
2 answers
34 views

Bash receive stderr from a pipe which did not redirect it

Is it possible to receive/redirect the stderr of foo.sh from within bar.sh if called without redirecting it first: foo.sh | bar.sh? foo.sh #!/bin/bash echo "hello world" >&2 bar.sh #!...
user avatar
0 votes
0 answers
63 views

BASH - Getting stderr message into a variable to be passed to a trap

My question is relative to Ubuntu 20.04 where I am performing these tasks. I currently pass some state information to a debug trap such as $BASH_COMMAND, $LINENO and $?. I would like to pass any ...
user avatar
1 vote
1 answer
48 views

can't get 2> to work on g++ command line on Ubuntu update

On a remote server that was updated with a newer version of Ubuntu, when I try to redirect stderr it won't work. Using putty from windows, but I've done it on the old server all the time. g++ ...
user avatar
0 votes
3 answers
76 views

Using `1>&- 2>&- &' as an alias after a shell command

To run a program with bash in background, with no text output, it is possible to use: 1>&- 2>&- &. I would like to define an alias for this. However, if I write in .bashrc alias ...
user avatar
  • 4,493
0 votes
1 answer
87 views

Why isn't "Permission denied" in stderr? [duplicate]

I have a command: mywritercmd -f /tmp/test 2>&1 > log.txt I run in a bash terminal, the command returns error: could not open output file "/tmp/test": Permission denied ...
user avatar
  • 432
1 vote
1 answer
112 views

Making Bash send this error to std error

While writing some Lua as a backend for my LuaTeX code I noticed the following. For background, here is the Lua code. This version is standard Lua. But you don't really need to understand Lua to ...
user avatar
  • 33.1k
1 vote
2 answers
155 views

Capture stdout of a crashing program and shell's "segfault error" message

I have a compiled program main.bin that is supposed to print: hello world another line This program generates a segmentation fault right after printing the first line. If I run it in the shell (zsh), ...
user avatar
0 votes
0 answers
19 views

Get Percentage of used memory in Solaris [duplicate]

I wish to get Percentage of used memory in Solaris as non-root user. The solution proposed here does not work for me and I get error. $ /usr/sbin/prtconf 2>/dev/null | /usr/bin/awk '/Memory/ {print ...
user avatar
  • 297
0 votes
1 answer
104 views

Does redirected stderr remain unbuffered in bash?

{ echo bla1 echo bla2 1>&2 } >>myfile 2>&1 Is there any difference between the two echo-s? The only difference I can think of, if echo bla2 2>&1 retains the unbuffered ...
user avatar
  • 411
0 votes
2 answers
126 views

How to capture output that is going neither to stdout nor to stderr?

As far as I can tell, some of the output generated by the command /usr/bin/modulecmd goes neither to stdout nor stderr, as illustrated by the following example: % /usr/bin/modulecmd bash help null >...
user avatar
  • 12.8k
-1 votes
1 answer
60 views

What type of buffering does stderr use by default (in linux)?

What type of buffering does the standard error stream use by default in Linux?
user avatar
0 votes
1 answer
92 views

Why is this shell output cannot be written to a file? [duplicate]

I'm working on a linux pinephone script that would launch a touchpad emulator. In order to do so, I need to compare the output string of: ./TouchpadEmulator /dev/input/event2 /dev/input/event1 once I ...
user avatar
0 votes
0 answers
51 views

How order of saving data redirected from stdout and stderr streams works?

I'm experimenting with redirecting and I've noticed some problem. I know that when I want to save stdout data and stderr data in the same file I can just use 2>&1 or shorten >& like: ls ...
user avatar
  • 181
2 votes
1 answer
62 views

Redirecting output from within disk operations does not work

I am not able to successfully redirect STDOUT+STDERR on commands that operates with disks. Standard redirecting which always works, is somehow now catching the output. Two practical examples: Example ...
user avatar
1 vote
1 answer
50 views

bash I/O redirection - how to append to stderr

I have a script that loops over some big collection of data and performs some lenghty operations. Then i need to sort | uniq -c its output. So to let it know that its alive, I print a dot every N ...
user avatar
  • 153
0 votes
0 answers
241 views

RuntimeError: 'v4l2loopback' backend: std::exception

I'm getting above error when I'm trying to execute following piece of code: import pyvirtualcam import numpy as np with pyvirtualcam.Camera(width=1280, height=720, fps=20) as cam: print(f'Using ...
user avatar
  • 1
0 votes
1 answer
84 views

process hangs after redirecting stderr using exec

I want to redirect stdout and stderr to 2 pipes one for each to create the pipes I used: mkfifo -m 0666 /var/run/log_stdout.pipe mkfifo -m 0666 /var/run/log_stderr.pipe and it works fine, but ...
user avatar
  • 1
1 vote
1 answer
101 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 &...
user avatar
0 votes
0 answers
458 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 ...
user avatar
0 votes
1 answer
48 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 ...
user avatar
  • 29
0 votes
1 answer
141 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 ...
user avatar
  • 197
1 vote
0 answers
64 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 ...
user avatar
0 votes
2 answers
516 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 >/...
user avatar
2 votes
1 answer
203 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 ...
user avatar
  • 23
1 vote
1 answer
154 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&...
user avatar
3 votes
1 answer
720 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 ...
user avatar
  • 4,843
-4 votes
2 answers
190 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 ...
user avatar
0 votes
1 answer
4k 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 ...
user avatar
  • 297
0 votes
1 answer
733 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 "${...
user avatar
  • 924
0 votes
1 answer
130 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 ...
user avatar
1 vote
1 answer
89 views

What does "export >/dev/stderr" mean?

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

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

I'm working on refactoring some Python scripts intended to be run from the command line. The scripts use logging, which makes some messages be written to STDERR (among other things). I wonder if it's ...
user avatar
-1 votes
3 answers
1k 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 > /...
user avatar
  • 1
13 votes
1 answer
4k 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 ...
user avatar
2 votes
1 answer
82 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 ...
user avatar
  • 1,287
3 votes
1 answer
632 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 ...
user avatar
0 votes
3 answers
298 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 ...
user avatar
  • 758
-1 votes
1 answer
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 ...
user avatar
0 votes
1 answer
338 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 ...
user avatar
  • 653
1 vote
4 answers
2k 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 ...
user avatar
1 vote
1 answer
207 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 ...
user avatar
  • 2,647
2 votes
1 answer
237 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 ...
user avatar
  • 530
2 votes
1 answer
662 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:~$ ...
user avatar
0 votes
0 answers
277 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 ...
user avatar
  • 101
0 votes
1 answer
171 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 ...
user avatar
  • 23
2 votes
1 answer
555 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 ...
user avatar
  • 124

1
2 3 4 5