Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [stdout]

stdout is the name of the default output file descriptor of a process. Since there is nothing special about `stdout`, you *should not* use this tag. Use [tag:io-redirection] for questions on how to redirect output, use [tag:file-descriptors] for questions on how to manage file descriptors, use [tag:lock] for questions of file locking, and use [tag:files] for general questions on file operations.

3
votes
2answers
232 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 ...
1
vote
1answer
23 views

How to prevent printing to stdout from an awk **script** (not from cli)

[GNU awk v4.2.1 on Archlinux] Suppressing awk's default print action to stdout from cli is easy and well documented on UL, e.g. here. Doing so from a script gives me headaches. Here's the toy script: ...
0
votes
1answer
39 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 ...
2
votes
1answer
34 views

Redirecting stdout and stderr from a bash script inside a bash script

I know that I can re-direct stdout and stderr from a script to a file such as follows, if this is executed directly on the command line : sh myscript1.sh &>output.txt & However if I ...
0
votes
1answer
72 views

Commands leaking characters to bash

While building a small expect script I noticed that, after executing the script, some characters were automatically on the input of bash. I have seen that on other programs before, but here I have ...
0
votes
2answers
49 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
30 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
55 views

Capture output of a command, process it and ONLY then output to terminal

I would like to capture the stdout (as sent to a terminal), and perform some processing after it is output on the terminal (for the user). I want to know how to grab the output, process and make ...
0
votes
2answers
24 views

Repeat command execution attempts until status is not specific, preserve data

I have a case where a first few command execution attempts after daemon restart are returning 2 (followed by stderr messages), than everything works correctly. In order to bypass this bug I've come ...
9
votes
1answer
594 views

Redirecting stdout from two programs

I'm running a memory check tool (prog1) on a C++ code (prog2), both of which give me a huge and detailed output. In order to chase down some bugs I need to save this output to a file. I tried ...
0
votes
2answers
58 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). ...
0
votes
1answer
24 views

Redirecting stdout makes modem unable to connect

I'm running Yocto with busybox on an embedded system with a Telit modem. If I launch the main program, script A, with ./script_A & there's no problem at all and the modem connects on the first ...
1
vote
1answer
22 views

A command wants file paths. How can I give it stdin for the “infile” and stdout for the “outfile”?

Consider a command like foo -in /path/to/infile -out /path/to/outfile, that you'd like to pass strings to rather than using temp files. It may be called a lot causing much disk access, or is related ...
1
vote
1answer
127 views

How does sponge (from moreutils) work?

sponge can “soak up” stdin and write it atomically to a file, enabling one to do cat f|sponge a. I want to know how exactly it accomplishes this. How does it know when the input is finished?
0
votes
3answers
30 views

If-condition based on standard output

I have few commands linked through pipes, and at the end is a conditional awk: example below command1 | command 2 | awk '$1 > 800' Now sometimes it will output few lines, and sometimes no lines. ...
-5
votes
1answer
244 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 ...
13
votes
2answers
832 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/...
1
vote
4answers
602 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
347 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/...
3
votes
2answers
52 views

How does `cat`'s I/O model differ from that of other utilities?

From the output of stdbuf --help (GNU): Usage: stdbuf OPTION... COMMAND Run COMMAND, with modified buffering operations for its standard streams. ... NOTE: If COMMAND adjusts the buffering of its ...
0
votes
2answers
68 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 "...
1
vote
2answers
154 views

Print netcat input on terminal

I'm trying to write a script where I cat the content of a file and pipe it into nc: $cat somefile.txt | nc server port The file content is sent to the server as expected but on the terminal I only ...
4
votes
2answers
393 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 ...
1
vote
1answer
125 views

python script output won't be directed to file

I have a python script. It has a SimpleLogger with sys.stdout as output_stream. logger = SimpleLogger(level=LogLevel.DEBUG) When I run it in console, I get the logs properly, but whenever I ...
0
votes
0answers
31 views

difference between > and >| [duplicate]

I do not understand the very difference between 1. [n]> word 2. [n]>[|]word https://ss64.com/bash/syntax-redirection.html I tried both: $ ls -l file > word $ ls -l file >| word ...
3
votes
1answer
69 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
0
votes
1answer
231 views

Is there any difference between tee and >> when using echo?

Is there any difference beteween doing: echo "hahaha" >> file1 and echo "hahaha" |tee -a file1 ? Yes, I noticed that I cannot write to write protected files even aith sudo echo, but I can ...
1
vote
2answers
215 views

How to detect whether a string is present in stdout without affecting the output? [duplicate]

I have a program called my_program that prints diagnostic message to stdout I want to detect if the diagnostic messages includes string "TEST FAILURE" and if it does, execute some command after the ...
2
votes
2answers
57 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 ...
-1
votes
1answer
2k views

Why does echo <<EOF … EOF not work [duplicate]

Just wondering if anyone can explain why this works: echo `cat <<EOF {"branch":"foo","value":"bar"} EOF` but this doesn't: echo <<EOF {"branch":"foo","value":"bar"} EOF (the second ...
3
votes
2answers
285 views

Using pipe STDOUT as a variable?

Fairly new to Bash, about a grueling week. I love it so far and really like long chaining pipes. What I'm noticing though is that I have to break the pipe if I need to use the STDOUT as a variable. ...
2
votes
2answers
78 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 ...
1
vote
1answer
48 views

Does Ctrl-C (SIGINT) prevent output to be shown even if there were processes trying to output it

I had a bash script which did the wrong thing. So I pressed Ctrl-C to stop it. Is now the output I currently see on my terminal all the output produced by the processes that have run. Are does Ctrl-...
5
votes
4answers
441 views

How do I prefix commandline output with a fixed string? [duplicate]

Suppose I run the command: sudo ./list_members Physicians And I want to prefix the output like this: Physicians user@domain.com Physicians user2@domain.com Physicians user3@domain.com Physicians ...
5
votes
2answers
152 views

Standard Out Append to File Size Limitations

I'm pulling VIN specifications from the National Highway Traffic Safety Administration API for approximately 25,000,000 VIN numbers. This is a great deal of data, and as I'm not transforming the data ...
0
votes
2answers
182 views

Why not write to stdin?

According to this answer, stdin, stdout, and stderr are all initially connected to the same place (same as /dev/tty), and the convention of reading from stdin and writing to stdout and stderr is only ...
1
vote
1answer
208 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 ...
0
votes
1answer
476 views

Getting subprocess.Popen stdout when running by cron

I want to get a service status and if it's not up, to send the status (stdout) in email. This script is scheduled to run every hour by cron. When running manually, the following works fine: def ...
2
votes
1answer
211 views

Why stdout won't flush when redirecting input from a fifo?

I have a program that displays a prompt message and waits for the user to input some text. $ program Input a line of text: <aaaa> Some more output. $ Now, I also want to be able to provide ...
0
votes
1answer
60 views

Why `tail -f data_log | grep keyword` within tmux session could lead to hard disk exhaustion?

The scene is like, yesterday I need to check some api bug. So I logged into the log server. I opened up a tmux session, so I can reconnect to my work later. I typed in tail -f data_log | grep keyword ...
0
votes
1answer
75 views

How do I output what wget retrieves to stdout and suppress all other wget messaging?

I'm using bash shell on Amazon Linux. I have a command in a shell script wget -O - "http://localhost:8088/subco/books/$e_id/segments/$segment_id?product=$product_id&audience=teacher" > /dev/...
2
votes
0answers
167 views

How to view daemon stdout in openrc?

How do I find stdout of a process in openrc? Here's how I created my daemon. /etc/init.d/mydaemon #!/sbin/openrc-run command="python3" command_args="/srv/http/tornado.py" command_background="yes"...
1
vote
1answer
266 views

systemd.service : use pty so force flush of stdout?

I have a service that I want to run under systemd. It is written in perl, where by default output is line buffered if STDOUT is connected to a terminal. (Which seems similar to python) The ...
1
vote
2answers
632 views

Execute command and store everything to variable in bash

In bash script I'm developing I'm trying to execute command and capture in variable(s): stdout stderr status code how to achieve that? The command is tar, if it is of any significance. I tried the ...
0
votes
1answer
120 views

Change stdout/stderr output device

By default if we run foo(){ echo "myfoo" } it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't ...
0
votes
3answers
233 views

Read from file descriptor and write to stdout

I want to prepend something to each line of output in a script, for every command. I was thinking of doing something like this: rm foo mkfifo foo exec 3<>foo cat <&3 | while read line;...
0
votes
1answer
278 views

Append stderr and stdout to file

I have this: npm install "$tgz_path" &>> "$HOME/.r2g/logs/r2g.log"; but that is syntactically incorrect. How do I append stdout+stderr to that log file?
0
votes
1answer
44 views

stderr is being sent down pipeline but I don't want that

I have this: echo "$some_command" | bash 2> >(prepend 'r2g-stderr:' 'red') | prepend 'r2g-stdout:' 'yellow'; What I am trying to do: r2g-stderr: this is some stderr r2g-stderr: this is ...
1
vote
1answer
46 views

Send stderr to a different receiver in pipe

Right now I have this: echo "$run_test" | bash 2>&1 | prepend "r2g-test:" "yellow"; What this does is prepend "r2g-test:" to each line of the stdout/stderr. Because I am sending stderr to ...
4
votes
1answer
53 views

Determine if producer is outpacing consumer in pipeline

If I have: node foo.js | node bar.js is there a way to determine if there is a queue in between them that's building up? in other words if the producer is outpacing the consumer w.r.t. stdio?