Questions tagged [stdout]

The standard output stream (stdout) is the stream where a program writes its output data.

4740 questions
61
votes
5 answers

How to make python 3 print() utf8

How can I make python 3 (3.1) print("Some text") to stdout in UTF-8, or how to output raw bytes? Test.py TestText = "Test - āĀēĒčČ..šŠūŪžŽ" # this is UTF-8 TestText2 = b"Test2 -…
davispuh
  • 1,419
  • 3
  • 18
  • 30
59
votes
6 answers

pass stdout as file name for command line util?

I'm working with a command line utility that requires passing the name of a file to write output to, e.g. foo -o output.txt The only thing it writes to stdout is a message that indicates that it ran successfully. I'd like to be able to pipe…
Jake
  • 5,379
  • 6
  • 19
  • 19
59
votes
9 answers

Suppress stdout / stderr print from Python functions

I have a Python script that is using some closed-box Python functions (i.e. I can't edit these functions) provided by my employer. When I call these functions, they are printing output to my linux terminal that I would like to suppress. I've tried…
jeremiahbuddha
  • 9,701
  • 5
  • 28
  • 34
58
votes
4 answers

Interactive input/output using Python

I have a program that interacts with the user (acts like a shell), and I want to run it using the Python subprocess module interactively. That means, I want the possibility to write to standard input and immediately get the output from standard…
Talor Abramovich
  • 801
  • 1
  • 6
  • 9
58
votes
10 answers

Capturing stdout from a system() command optimally

I'm trying to start an external application through system() - for example, system("ls"). I would like to capture its output as it happens so I can send it to another function for further processing. What's the best way to do that in C/C++?
SinisterDex
  • 811
  • 2
  • 10
  • 13
58
votes
5 answers

How do I see stdout when running Django tests?

When I run tests with ./manage.py test, whatever I send to the standard output through print doesn't show. When tests fail, I see an "stdout" block per failed test, so I guess Django traps it (but doesn't show it when tests pass).
agentofuser
  • 8,987
  • 11
  • 54
  • 85
58
votes
6 answers

How do you capture stderr, stdout, and the exit code all at once, in Perl?

Is it possible to run an external process from Perl, capture its stderr, stdout AND the process exit code? I seem to be able to do combinations of these, e.g. use backticks to get stdout, IPC::Open3 to capture outputs, and system() to get exit…
Scooby
  • 755
  • 2
  • 7
  • 9
57
votes
8 answers

Should the command line "usage" be printed on stdout or stderr?

When printing the "usage" of an application, should it be done on stdout or on stderr? Depending on the application I've seen several cases, but there doesn't seem to be one rule. Maybe I'm mistaken and there is one good practice. In that case, what…
Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137
57
votes
7 answers

What does it mean to write to stdout in C?

Does a program that writes to "stdout" write to a file? the screen? I don't understand what it means to write to stdout.
Acroyear
  • 1,354
  • 3
  • 22
  • 37
57
votes
2 answers

Capturing process output via OutputDataReceived event

I'm trying to capture process output in "realtime" (while it's running). The code I use is rather simple (see below). For some strange reason the OutputDataReceived event is never called. Why? private void button2_Click(object sender, EventArgs e) …
Boris
  • 8,551
  • 25
  • 67
  • 120
57
votes
7 answers

Redirect Python 'print' output to Logger

I have a Python script that makes use of 'Print' for printing to stdout. I've recently added logging via Python Logger and would like to make it so these print statements go to logger if logging is enabled. I do not want to modify or remove these…
Rauffle
  • 957
  • 2
  • 8
  • 14
56
votes
3 answers

Piping output of subprocess.Popen to files

I need to launch a number of long-running processes with subprocess.Popen, and would like to have the stdout and stderr from each automatically piped to separate log files. Each process will run simultaneously for several minutes, and I want two log…
user280867
55
votes
7 answers

Capture program stdout and stderr to separate variables

Is it possible to redirect stdout from an external program to a variable and stderr from external programs to another variable in one run? For example: $global:ERRORS = @(); $global:PROGERR = @(); function test() { # Can we redirect errors to…
dusz
  • 913
  • 1
  • 9
  • 15
51
votes
7 answers

Merging a Python script's subprocess' stdout and stderr while keeping them distinguishable

I would like to direct a python script's subprocess' stdout and stdin into the same file. What I don't know is how to make the lines from the two sources distinguishable? (For example prefix the lines from stderr with an exclamation mark.) In my…
beemtee
  • 831
  • 1
  • 8
  • 10
51
votes
2 answers

How to capture standard output of a shell command in elisp?

I want to run a shell command within Emacs and capture the full output to a variable. Is there a way to do this? For example, I would like to be able to set hello-string to "hello" in the following manner: (setq hello-string…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159