The standard output stream (stdout) is the stream where a program writes its output data.
Questions tagged [stdout]
4740 questions
34
votes
8 answers
How to overwrite stdout in C
In most modern shells, you can hit the up and down arrows and it will put, at the prompt, previous commands that you have executed. My question is, how does this work?!
It seems to me that the shell is somehow manipulating stdout to overwrite what…

Scott
- 10,407
- 13
- 37
- 35
34
votes
6 answers
Live stdout output from Python subprocess in Jupyter notebook
I'm using subprocess to run a command line program from a Python (3.5.2) script, which I am running in a Jupyter notebook. The subprocess takes a long time to run and so I would like its stdout to be printed live to the screen in the Jupyter…

Johnny Hunter
- 341
- 1
- 3
- 4
34
votes
1 answer
Redirecting stdout and stderr to a PyQt4 QTextEdit from a secondary thread
Stack overflow. Once again, I come to you in a time of dire need, teetering precariously on the brink of insanity. This question - as may be evident from the title - is an amalgamation of several other questions I have seen answered here.
I have a…

araisbec
- 1,223
- 3
- 16
- 27
34
votes
6 answers
How to redirect the output back to the screen after freopen("out.txt", "a", stdout)
#include
int main() {
printf("This goes to screen\n");
freopen("out.txt", "a", stdout);
printf("This goes to out.txt");
freopen("/dev/stdout", "a", stdout);
printf("This should go to screen too, but doesn't\n");
…

Hoffmann
- 14,369
- 16
- 76
- 91
34
votes
2 answers
How do you edit existing text (and move the cursor around) in the terminal?
I saw this demo once that printed out a paragraph of text (like you'd get when typing some-command --help), and it then jumped back up to a couple keywords in the text and changed the text color, after it was already printed out in the…

Lance
- 75,200
- 93
- 289
- 503
33
votes
6 answers
Redirecting stdout to file nodejs
I've created:
var access = fs.createWriteStream('/var/log/node/api.access.log', { flags: 'w' });
Then piped:
process.stdout.pipe(access);
Then tried:
console.log("test");
And nothing has appeared in /var/log/node/api.access.log. However this way…

Supervision
- 1,683
- 1
- 18
- 23
33
votes
4 answers
How to log output in bash and see it in the terminal at the same time?
I have some scripts where I need to see the output and log the result to a file, with the simplest example being:
$ update-client > my.log
I want to be able to see the output of the command while it's running, but also have it logged to the file. I…

Kristopher Ives
- 5,838
- 7
- 42
- 67
33
votes
3 answers
How to test a function's output (stdout/stderr) in unit tests
I have a simple function I want to test:
func (t *Thing) print(min_verbosity int, message string) {
if t.verbosity >= minv {
fmt.Print(message)
}
}
But how can I test what the function actually sends to standard output? Test::Output…

Jonathan Hall
- 75,165
- 16
- 143
- 189
32
votes
1 answer
does echo equal fputs( STDout )?
Does echo equal fputs( STDOUT ), or does echo write to a different stream? I've used PHP for a while now, but I don't know very well what's actually happening on a lower level.

bigblind
- 12,539
- 14
- 68
- 123
32
votes
1 answer
On a Linux system, how would I redirect stdout to stderr?
I think its the case that you can't just assign the stdout to stderr because other things might have already cached (?) stdout by the time the reassignment takes place.
So how do I do this (using Linux)?

nodebase
- 2,510
- 6
- 31
- 46
32
votes
4 answers
Multiple inputs and outputs in python subprocess communicate
I need to do something like this post, but I need to create a subprocess that can be given input and give output many times. The accepted answer of that post has good code...
from subprocess import Popen, PIPE, STDOUT
p = Popen(['grep', 'f'],…

reynoldsnlp
- 1,072
- 1
- 18
- 45
32
votes
4 answers
Python - reset stdout to normal, after previously redirecting it to a file
At the beginning of my python program I have the following line:
sys.stdout = open('stdout_file', 'w')
Halfway through my program I would like to set stdout back to the normal stdout. How do I do this?

tadasajon
- 14,276
- 29
- 92
- 144
31
votes
4 answers
Add new line in text file with Windows batch file
I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows XP.
Example text file before input:
header 1
header 2
header 3
details 1
details 2
After output:
header 1
header 2
header…

newbie18
- 323
- 1
- 3
- 6
31
votes
1 answer
Redirect stdout to a string in Java
I know how to redirect the stdout to a file, but I have no idea on how to redirect it to a string.

Fengqian Li
- 313
- 1
- 3
- 7
31
votes
4 answers
How to store the output of a command in a variable at the same time as printing the output?
Say I want to echo something and capture it in a variable, at the same time I see it in my screen.
echo "hello" | tee tmp_file
var=$(< tmp_file)
So now I could see hello in my terminal as well as saving it into the variable $var.
However, is there…

fedorqui
- 275,237
- 103
- 548
- 598