The standard output stream (stdout) is the stream where a program writes its output data.
Questions tagged [stdout]
4740 questions
21
votes
5 answers
Can anyone give me a quick tutorial in stdin and stdout in Python 3?
I know this sounds like something I can google, but the truth is that I don't find or do not understand what the very few Python 3 sources explains.
So here are my questions:
Is input() the stdin function in Python 3? Does that mean that when you…

Martin Hallén
- 1,492
- 1
- 12
- 27
21
votes
3 answers
Chain of piped commands, each outputting status to standard error
I have a chain of piped commands in a bash script, piping standard output to standard input:
prog1 | prog2 | prog3
and they each output something to standard error. Some of them output overwriting the previous line, some do not, some do both: e.g.…

Michal Charemza
- 25,940
- 14
- 98
- 165
21
votes
3 answers
Capturing contents of standard output in Java
I am invoking a function that is printing some string in my console/standard output. I need to capture this string. I cannot modify the function that is doing the printing, nor change runtime behavior through inheritance. I am unable to find any…

Shailesh Tainwala
- 6,299
- 12
- 58
- 69
21
votes
4 answers
How to execute a command and get return code stdout and stderr of command in C++
Given the following answer (first c++11 answer):
How do I execute a command and get the output of the command within C++ using POSIX?
Here is the implementation for your convenience:
#include
#include
#include
#include…

code_fodder
- 15,263
- 17
- 90
- 167
21
votes
3 answers
How do I avoid getting data printed to stdout in my return value?
In doing some Powershell automation, I'm having trouble with the way that data written to stdout by a .cmd file is automatically captured. I have two functions that do something like the following:
function a {
& external.cmd # prints "foo"
…

JSBձոգչ
- 40,684
- 18
- 101
- 169
21
votes
3 answers
How to capture a Processes STDOUT and STDERR line by line as they occur, during process operation. (C#)
I am going to execute a Process (lame.exe) to encode a WAV file to MP3.
I want to process the STDOUT and STDERR of the process to display progress information.
Do I need to use threading? I can't get my head around it.
Some simple example code would…

dave
- 273
- 2
- 5
21
votes
2 answers
How to print stdout immediately?
How can I immediately output stdout? stdout is going to print after all input is complete.
require 'open3'
def run(cmd)
Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
Thread.new do
stdout.each {|l| puts l}
end
…

xitryuga
- 323
- 1
- 2
- 9
21
votes
4 answers
How to change the stdin and stdout encoding on Python 2
I'm using Windows and Linux machines for the same project. The default encoding for stdin on Windows is cp1252, and on Linux it is utf-8.
I would like to change everything to utf-8.
Is it possible? How can I do it?
This question is about Python 2;…

duduklein
- 10,014
- 11
- 44
- 55
21
votes
5 answers
Output binary data on PowerShell pipeline
I need to pipe some data to a program's stdin:
First 4 bytes are a 32-bit unsigned int representing the length of the data. These 4 bytes are exactly the same as C would store an unsigned int in memory. I refer to this as binary data.
Remaining…

johnnycrash
- 5,184
- 5
- 34
- 58
21
votes
1 answer
Redirect nohup's stderr to nohup.out
How do I run a command with nohup so that both the stdout and stderr are saved to nohup.out? By default only stdout is saved and stderr is discarded.

Timmmm
- 88,195
- 71
- 364
- 509
20
votes
4 answers
Ordering Output in MPI
in a simple MPI program I have used a column wise division of a large matrix.
How can I order the output so that each matrix appears next to the other ordered ?
I have tried this simple code the effect is quite different from the wanted:
for(int…

GBBL
- 576
- 1
- 6
- 18
20
votes
7 answers
VBscript code to capture stdout, without showing console window
This is a VBScript code example that shows how to catch whatever a command line program sends to standard output.
It executes the command xcopy /? and shows the output in a message box. Before the message box appears, for a split second you see the…

mgr326639
- 902
- 2
- 10
- 24
20
votes
2 answers
Test output to php://stdout with PHPUnit
I am using Symfony\Component\Console\Output\ConsoleOutput to write to the console.
Explicitly, I am writing to php://stdout.
In my unit tests, I would like to be able to check the output to the console.
Using the PHPUnit method expectOutputString(),…

Jonathan Maron
- 633
- 1
- 5
- 11
20
votes
2 answers
Possible to capture PHP echo output?
So I have a function such as:
public static function UnorderedList($items, $field, $view = false){
if(count($items) > 0){
echo '
- ';
foreach($items as $item){
echo '
- '; if($view){ …

Chris
- 11,780
- 13
- 48
- 70
20
votes
6 answers
How to capture print output of another module?
I was wondering if this is possible in python:
# module1
def test():
print('hey')
# module2
import module1
module1.test() # prints to stdout
Without modifying module1 is there any way to wrap this in module2 so that I can capture…

waka-waka-waka
- 1,025
- 3
- 14
- 30