Stack Exchange Network

Stack Exchange network consists of 174 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.

-1
votes
1answer
46 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 ...
1
vote
0answers
15 views

Python: piping pcap file to stdout gives error [migrated]

I am trying to pipe the output of xz to a custom python script: xz -cd file.xz | myscripy.py However, I get an error when the script attempts to run this line: #!/usr/bin/env python2.7 from ...
9
votes
1answer
584 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
0answers
35 views

Can't parse tcpdump output correctly

I'm trying to run this command: sudo tcpdump "ether proto 0x888e and ether host <BSSID>" -I -w -U -vvv -I <INTERFACENAME> -w ~/Desktop/handshake.cap which works perfectly in terms of its ...
0
votes
2answers
46 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
21 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
20 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
78 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
230 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 ...
0
votes
0answers
41 views

write STDOUT and STDERR to screen AND file, in order, while flagging STDERR lines so they can be easily grepped

I have seen numerous questions like this but all of them are old, and none have any good answers -- just ugly hacks that don't really do what is wanted. I figured its 2018 and there must be a good ...
13
votes
2answers
723 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
222 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
297 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
49 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
59 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
97 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
317 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
61 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
29 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
56 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
128 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
133 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
49 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
893 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
197 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
71 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
45 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
297 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
144 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
167 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
126 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
373 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
183 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
58 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
61 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
135 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
238 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
154 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
78 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
164 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
238 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
40 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
45 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
50 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?
0
votes
1answer
36 views

SysRq output into |less, |more, |tee?

If I issue a SysRq command, how do I redirect that output (whether it is stdout or stderr is documented nowhere) to |less, |more or |tee?
0
votes
2answers
112 views

Controlling curl output on Debian

I'd like to run a curl command and only have content written to stdout if there is an error. When I run the command from the terminal I get this functionality by default. When I run the command from ...
0
votes
2answers
309 views

Prepend string before each line of stdin

I have this script which sends logs from each Kubernetes pod to stdout: #!/usr/bin/env bash set -e; oc project cdt-dev pods=$(oc get pods --show-all=false -o name) for j in ${pods}; do oc ...
1
vote
1answer
237 views

How does a temporary file differs from a pipe? [duplicate]

When one sends data (say stdout) to a temporary file, it is likely that something would be done with that data (the temporary file will be used as stdin for some process), then the temporary file will ...