The standard output stream (stdout) is the stream where a program writes its output data.
Questions tagged [stdout]
4740 questions
17
votes
2 answers
NodeJS spawn stdout string format
I'm spawning a process in node and tracking the output of the command like this:
proc.stdout.on("data", function (data) {
console.log(data.toString());
});
It works well, however, the output seems to be splitting the lines:
npm http
304…

Fluidbyte
- 5,162
- 9
- 47
- 76
17
votes
5 answers
What is “standard input”?
I was tasked with creating a test program in C that reads the contents of the standard input and then prints them.
But I have a little doubt: what is exactly standard input?
Is it what I type in the keyboard? Is it a file I have to read?
Both of…

Kio Marv
- 337
- 2
- 3
- 8
17
votes
2 answers
capture process stdout and stderr in the correct ordering
I launch a process from C# as follows:
public bool Execute()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "the command";
startInfo.FileName = "C:\\MyApp.exe";
startInfo.UseShellExecute = false;
…

paulm
- 5,629
- 7
- 47
- 70
17
votes
3 answers
Is there a guarantee of stdout auto-flush before exit? How does it work?
Here is the code (valid C and C++)
#include
int main() {
printf("asfd");
// LINE 1
return 0;
}
If in line 1 I put segfaulting expression the program would just crash without printing anything (as expected).
But why is the…

sasha.sochka
- 14,395
- 10
- 44
- 68
17
votes
3 answers
How can I reinitialize Perl's STDIN/STDOUT/STDERR?
I have a Perl script which forks and daemonizes itself. It's run by cron, so in order to not leave a zombie around, I shut down STDIN,STDOUT, and STDERR:
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die…

Josh
- 4,412
- 7
- 38
- 41
17
votes
1 answer
Why does wget output to stderr rather than stdout?
After 30mins of futile attempt to capture the output of wget, I figured out that the program writes to stderr rather than the stdout. Searching in web and stack-overflow reveals this to be a well-known fact.
Any idea why is this so?

BiGYaN
- 6,974
- 5
- 30
- 43
16
votes
3 answers
Capturing stdout/stderr with NDK
I am porting some existing C code to run on Android. This C code writes lots of output to stdout/stderr. I need to capture this output, either in a memory buffer or a file, so I can then send it by email or otherwise share it.
How can I achieve…

Graham Borland
- 60,055
- 21
- 138
- 179
16
votes
3 answers
Asynchronously redirect stdout/stdin from embedded python to c++?
I am essentially trying to write a console interface with input and output for an embedded python script. Following the instructions here, I was able to capture stdout:
Py_Initialize();
PyRun_SimpleString("\
class StdoutCatcher:\n\
def…

Josh Kirklin
- 929
- 5
- 14
16
votes
6 answers
How to redirect STDOUT and STDERR to a variable
I want to redirect STDERR and STDOUT to a variable. I did this.
close(STDOUT);
close(STDERR);
my $out;
open(STDOUT, ">>", \$out);
open(STDERR, ">>", \$out);
for(1..10)
{
print "print\n"; # this is ok.
warn "warn\n"; # same
…

Deck
- 1,969
- 4
- 20
- 41
16
votes
2 answers
Redirecting STDIN, STDOUT, STDERR to /dev/null in C
In Stevens' UNIX Network Programming, he mentions redirecting stdin, stdout and stderr, which is needed when setting up a daemon. He does it with the following C code
/* redirect stdin, stdout, and stderr to /dev/null */
open("/dev/null",…

Paul
- 161
- 1
- 1
- 3
16
votes
4 answers
Disable buffering on redirected stdout Pipe (Win32 API, C++)
I'm spawning a process from Win32 using CreateProcess, setting the hStdOutput and hStdError properties of STARTUPINFO to pipe handles created with CreatePipe. I've got two threads reading the pipes, waiting for data to become available (or the…

Dave Brotherstone
- 620
- 1
- 5
- 11
16
votes
3 answers
How can I redirect the stdout of IronPython in C#?
I have the following:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
try
{
var strExpression = @"
…

Begtostudy
- 1,374
- 4
- 13
- 28
16
votes
3 answers
Python multiple subprocess with a pool/queue recover output as soon as one finishes and launch next job in queue
I'm currently launching a subprocess and parsing stdout on the go without waiting for it to finish to parse stdout.
for sample in all_samples:
my_tool_subprocess = subprocess.Popen('mytool {}'.format(sample),shell=True, stdout=subprocess.PIPE)
…

gmarco
- 535
- 3
- 8
- 16
16
votes
2 answers
whiptail: How to redirect output to environment variable?
I'm trying to use whiptail as it's a lightweight alternative to dialog and seems to be installed by default in most systems (i.e., people don't have to go around and install it if it's "forgotten" or wasn't installed by default).
I checked question…

jbatista
- 2,747
- 8
- 30
- 48
16
votes
1 answer
Getting output of a system command from stdout in C
I'm writing a C program under Android/Linux that runs a system command. The command outputs some text to stdout, and I'm trying to capture the output into a string or character array.
For example:
system("ls");
would list the contents of the…

user1118764
- 9,255
- 18
- 61
- 113