Questions tagged [stderr]
Standard error is another output stream typically used by programs to output error messages or diagnostics.
243
questions
2
votes
1
answer
91
views
In zsh, annotate each line in a file to which both stdout and stderr have been redirected with the line's source (stdout or stderr)
In zsh, how can I annotate each line in a file to which both stdout and stderr have been redirected with the line's source (stdout or stderr)?
I want output with the source name prepended to the line, ...
0
votes
1
answer
46
views
How can I get stderr from mbuffer written to log file when using tee?
Having a bash script that essential only doing:
mbuffer --md5 -i dummy.tar -o /dev/null
A user of this script wants to use tee and store the output messages in a log file.
./script.sh 2>&1 | ...
0
votes
1
answer
95
views
How to put all function/command call output results to different corresponding vars: for stderr, for stdout, for string result and for return code?
I want to extend question How to store standard error in a variable and get general solution (bash function or functions) to extract from the called function/command together with standard error also ...
1
vote
2
answers
175
views
Is it possible to read from stderr in a bash script?
I have a bash script like this:
#!/bin/bash
while read -r -a line
do
... parse $line in some way
done
This script is executed by piping the command from another program:
some-random-program | ...
0
votes
0
answers
23
views
How to redirect after merge [duplicate]
I'm trying to get the exit code of an ls command with no other output. To do this I'm using
ls /foo/bar/rak/zif/poo 2>&1 > /dev/null; echo $?
But when I do this, I get a ls: cannot access /...
4
votes
0
answers
226
views
Bash: Stderr being sent to a file (when it shouldn't be!)
The following code is on macOS as part of /etc/bashrc_Apple_Terminal, in order to save and restore the shell state across all open windows and tabs (note that this is therefore the very old bash 3.2....
0
votes
0
answers
54
views
When I ssh to the host in pycharm,after displaying 'Starting the remote IDE backend' for a long time,there shows a Deploy Failed window
Here.
They are "nohup:ignoring input" and "stderr is empty".
By the way,in the previous try the number of "nohup:ignoring input" was 3.
And then I remove that connection ...
3
votes
3
answers
960
views
When and where are the standard in, out, and error file descriptors first opened in linux?
Where are stdin, stdout, and stderr (the fds) first opened? Is it the kernel that does it? And when and where are the symlinks /dev/std{in,out,err} made? Where is the code that does it?
I assume it is ...
0
votes
1
answer
121
views
Calling a script from within csh with output redirection
What I would want:
#!/bin/csh
# call /myscriptpath/myscript.any and redirect 2>&1 and get retval and output
set my_msg = `/myscriptpath/myscript.any`
set my_ret = `echo $?`
How to capture the ...
1
vote
1
answer
73
views
Find number of process running using fuser
We are using fuse to find the logs associated to particular port.
fuser /test/log*
This results in a list of logs associated with port
How to find the number of lines on the output?
I tried with |wc -...
4
votes
1
answer
893
views
How can I remove this annoying message: "Failed to find cgroup2 mount"?
I run this command
ss -tulpnoea|grep -i water|grep -v 127
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 mount
Failed to find cgroup2 ...
0
votes
0
answers
101
views
Already using stderr, how do I detect if there was an error in a bash script
I am backing small databases from several websites and sending the admin an email with the results. I have already directed stderr to send the complete error in the email. Is there a way I can ...
1
vote
1
answer
159
views
Redirect stderr doesn't show python input
I am running the following command on the terminal:
python -c "input('Message')" 2> log
but the Message doesn't appear on the screen. Any ideas why this happens?
3
votes
1
answer
1k
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
306
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":...
0
votes
0
answers
414
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
220
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 - ...
4
votes
1
answer
14k
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
849
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 [...
0
votes
1
answer
1k
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
52
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 ...
1
vote
1
answer
950
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?
0
votes
2
answers
362
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
69
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 ...
0
votes
0
answers
255
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
2k
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
53
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
219
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
490
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 ...
1
vote
1
answer
72
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
367
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 ...
0
votes
1
answer
618
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
...
2
votes
1
answer
414
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 ...
2
votes
2
answers
1k
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
865
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 ...
0
votes
2
answers
1k
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 >...
1
vote
1
answer
787
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
101
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
225
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
74
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 ...
0
votes
0
answers
618
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
vote
1
answer
350
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 ...
2
votes
1
answer
431
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 &...
1
vote
0
answers
2k
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
1
answer
392
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
1
answer
588
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
0
answers
240
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
933
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 >/...
3
votes
1
answer
692
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
1
answer
463
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&...