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
1 answer
79 views

Make grep exit 1 if found, and exit 0 if not found

I'm creating a simple command to execute within GitHub Actions, which builds a Makefile and returns an error if found (matching Error 1) and success when not found... I seem to either get it to fail ...
0 votes
1 answer
88 views

Archive verify `gzip -v -t` prints success to stderr or I'm doing something wrong? [duplicate]

I want to add gzip file verification to my backup script. My backup script creates logs for stdout and stderr like this: scp -i $BCKIDENTITYFILE $BCKLOG "$BCKREMOTEUSER"@"$BCKHOST":...
  • 699
0 votes
0 answers
30 views

How to view the output of a running process in another bash session on mac?

I have a process running and I would like to know what it prints to stdout and stderr. On linux I would do tail -f /proc/<pid>/fd/1 See here How do I do this on macOS?
0 votes
1 answer
40 views

Log the error for a whole && chain of commands (in Cron jobs)

In one of my cronjobs, I have a long &&-chained command, at the end of which, I put 2>>/home/myparadise/public_html/wp-content/uploads/import/files/raytheon/raytheon_log_error.txt - ...
  • 5,265
0 votes
1 answer
833 views

Make apt install ignore missing packages

I often find myself doing this: :~$ sudo apt install php7.4 mysql-server git composer curl apache2 --yes To which I sometimes get this response: Reading package lists... Done Building dependency tree.....
0 votes
3 answers
145 views

How can I log shell errors in scripts called by a cron job?

This morning I found a message saying just so: EDIT: I add the header of the message as well, so it is clear where it came from. Return-Path: <root@REDACTED> Received: from localhost (localhost [...
  • 137
1 vote
1 answer
232 views

/bin/sh: capture stderr into a variable [duplicate]

In my script, I have a complicated command that generates output both on stdout and stderr. I need to capture both into separate variables: #!/bin/sh A=$(command) How can I "capture" stderr ...
3 votes
1 answer
32 views

Ambiguous bash stream redirection

I am trying to understand the Bash redirections (3.6. Redirections). I prepared the test envronment and I'm trying to understand the order of operations with redirections and order of created file ...
  • 131
1 vote
1 answer
74 views

pipe and tee doesn't receive output in a file..(bash)

I wanted get the resout of ps command to a file like this. (in bash) $ps -eax |& tee list1 and I see many lines from the ps command but the file list1 is empty. How should I do it?
  • 317
0 votes
2 answers
181 views

Fork stdin to stdout & stderr?

I am wondering if it's possible to fork standard input to stdout & stderr? Something like this, $ echo "hi" | fork > std.out 2> std.err $ cat std.out hi $ cat std.err hi Or, am I ...
0 votes
0 answers
58 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 ...
  • 9
0 votes
0 answers
217 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. ...
0 votes
0 answers
1k 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 ...
0 votes
1 answer
42 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 ...
0 votes
2 answers
44 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 #!...
1 vote
0 answers
211 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
55 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++ ...
0 votes
3 answers
132 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 ...
  • 4,677
0 votes
1 answer
297 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 ...
  • 545
2 votes
1 answer
257 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 ...
  • 34.2k
2 votes
2 answers
557 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), ...
1 vote
1 answer
346 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 ...
  • 433
0 votes
2 answers
557 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 >...
  • 14.2k
0 votes
1 answer
285 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?
0 votes
1 answer
98 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 ...
2 votes
1 answer
161 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 ...
1 vote
1 answer
62 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 ...
  • 163
0 votes
0 answers
435 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 ...
  • 1
0 votes
1 answer
228 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 ...
  • 1
1 vote
1 answer
244 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
0 answers
1k 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 ...
  • 1,071
0 votes
1 answer
188 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 ...
  • 53
0 votes
1 answer
306 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 ...
  • 308
1 vote
0 answers
143 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
2 answers
772 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
1 answer
381 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 ...
  • 23
1 vote
1 answer
295 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&...
3 votes
1 answer
1k 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,438
-3 votes
2 answers
308 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
8k 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 ...
  • 417
0 votes
1 answer
1k 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 "${...
  • 888
0 votes
1 answer
232 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
1 answer
156 views

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

I've found in a bash script following line: export >/dev/stderr what does it mean?
2 votes
3 answers
2k 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 ...
-1 votes
3 answers
3k 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 > /...
  • 1
15 votes
1 answer
6k 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
1 answer
111 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 ...
  • 1,423
3 votes
1 answer
857 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 ...
2 votes
3 answers
489 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 ...
  • 794
0 votes
1 answer
46 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 ...

1
2 3 4 5