Questions tagged [stdout]

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

4740 questions
25
votes
3 answers

Concatenate strings, files and program output in Bash

The use case is, in my case, CSS file concatenation, before it gets minimized. To concat two CSS files: cat 1.css 2.css > out.css To add some text at one single position, I can do cat 1.css < out.css This will end in the…
Boldewyn
  • 81,211
  • 44
  • 156
  • 212
25
votes
4 answers

Is there a way to catch the stderr and stdout in Visual Studio?

Is there a way to catch the stdout and stderr in Visual Studio? For example, when I use cout <<"Hello world!"<< endl; A black window appears and disappears. It's so fast that I can't see it. There is a output section in the IDE but it only allow me…
YankeeWhiskey
  • 1,522
  • 4
  • 20
  • 32
24
votes
7 answers

How to buffer stdout in memory and write it from a dedicated thread

I have a C application with many worker threads. It is essential that these do not block so where the worker threads need to write to a file on disk, I have them write to a circular buffer in memory, and then have a dedicated thread for writing…
NickB
  • 1,471
  • 4
  • 14
  • 20
24
votes
2 answers

Running an interactive command from within Python

I have a script that I want to run from within Python (2.6.5) that follows the logic below: Prompts the user for a password. It looks like ("Enter password: ") (*Note: Input does not echo to screen) Output irrelevant information Prompt the user for…
user1521597
  • 241
  • 1
  • 2
  • 3
23
votes
3 answers

Redirecting function output to /dev/null

I am using a library that is printing a warning message to cout or cerr. I don't want this warning message to reach the output of my program. How can I catch this output and put it into /dev/null or similar? MWE: #include void foo() { …
Unapiedra
  • 15,037
  • 12
  • 64
  • 93
23
votes
2 answers

Why is there no overload for printing `std::byte`?

The following code does not compile in C++20 #include #include int main(){ std::byte b {65}; std::cout<<"byte: "<
Quimby
  • 17,735
  • 4
  • 35
  • 55
23
votes
2 answers

How to capture the output of system()

This question was motivated by Rmarkdown not outputting results of system command to html file. For some reason, the output of system() in R (or system2()) cannot be captured by sink() or capture.output(), so currently there is no way for knitr to…
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
23
votes
4 answers

Where does "printf" write in a Windows Non-console Application?

If I choose to create a Windows Non-console Application, and implement printf/cout in the code, where does the printf/cout write? Does it write to the stdout buffer? If yes, is there any way to read it from stdout and print it to some text file or…
Abhineet
  • 5,320
  • 1
  • 25
  • 43
23
votes
2 answers

Redirect stdout and stderr from inside a batch file

Is there a way to redirect stdout and stderr for a batch file from inside it. I'm imagining something like set STDOUT=stdout.log echo Some text a.exe b.exe c.exe Where both Some text, and the output of a.exe, b.exe and c.exe would go to…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
23
votes
7 answers

IOError Input/Output Error When Printing

I have inherited some code which is periodically (randomly) failing due to an Input/Output error being raised during a call to print. I am trying to determine the cause of the exception being raised (or at least, better understand it) and how to…
Mark Streatfield
  • 3,189
  • 1
  • 22
  • 19
22
votes
2 answers

Python subprocess output to stdout

I am using the subprocess module to run binaries from python. To capture the output produced by the binary, I am using: proc = subprocess.Popen (command_args, shell=False, stdout=subprocess.PIPE) out = proc.communicate()[0] #print the output of the…
therealtypon
  • 455
  • 2
  • 5
  • 12
22
votes
9 answers

'\0' and printf() in C

In an introductory course of C, I have learned that while storing the strings are stored with null character \0 at the end of it. But what if I wanted to print a string, say printf("hello") although I've found that that it doesn't end with \0 by…
xrfxlp
  • 421
  • 5
  • 15
22
votes
5 answers

Need to avoid subprocess deadlock without communicate

I need a execute a command that produces a lot of output and takes a lot of time to execute (> 30 minutes). I was thinking of using subprocess.Popen to do it. I need to capture the output of the command, so I pass PIPE to stdout and stderr. A…
GDICommander
  • 1,273
  • 3
  • 15
  • 27
22
votes
2 answers

Set a Read-Only Attribute in Python?

Given how dynamic Python is, I'll be shocked if this isn't somehow possible: I would like to change the implementation of sys.stdout.write. I got the idea from this answer to another question of mine: https://stackoverflow.com/a/24492990/901641 I…
ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
22
votes
7 answers

Shell redirection i/o order

I'm playing with i/o shell redirection. The commands I've tried (in bash): ls -al *.xyz 2>&1 1> files.lst and ls -al *.xyz 1> files.lst 2>&1 There is no any *.xyz file in current folder. These commands gives me the different results. The first…
egor7
  • 4,678
  • 7
  • 31
  • 55