Questions tagged [stdout]

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

4740 questions
18
votes
5 answers

How to make print() output UTF-8 in Python 3.0?

I'm working in WinXP 5.1.2600, writing a Python application involving Chinese pinyin, which has involved me in endless Unicode problems. Switching to Python 3.0 has solved many of them. But the print() function for console output is not…
bigturtle
  • 371
  • 2
  • 3
  • 9
18
votes
2 answers

ansible parse text string from stdout

My problem is with ansible and parsing stdout. I need to capture the stdout from an ansible play and parse this output for a specific substring within stdout and save into a var. My specific use case is below - shell: "vault.sh --keystore…
TonyNguyen
  • 183
  • 1
  • 1
  • 5
18
votes
2 answers

bash variable capture stderr and stdout separately or get exit value

I need to capture the output and error of a command in my bash script and know whether the command succeeded or not. At the moment, I am capturing both like this: output=$(mycommand 2>&1) I then need to check the exit value of mycommand. If it…
mhost
  • 6,930
  • 5
  • 38
  • 45
18
votes
2 answers

What is the difference between error, stderr, stdout in node

I am using node.js and want to handle error messages. What are the differences between erro, stderr, stdout? When scripting shell, I redirected stderr and found useful error message and it solved the problem. I am not clear about the concept of what…
haeminish
  • 988
  • 5
  • 15
  • 29
18
votes
10 answers

using bash: write bit representation of integer to file

I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want: dd bs=1 if=file iseek=24 conv=block cbs=2 |…
Max Leske
  • 5,007
  • 6
  • 42
  • 54
18
votes
6 answers

Does reading from stdin flush stdout?

stdout is line-buffered when connected to a terminal, but I remember reading somewhere that reading (at least from stdin) will automatically flush stdout. All C implementations that I have used have done this, but I can't find it in the standard…
Thomas Padron-McCarthy
  • 27,232
  • 8
  • 51
  • 75
18
votes
5 answers

How can I display the output of a Opscode Chef bash command in my console?

I use Vagrant to spawn a standard "precise32" box and provision it with Chef so I can test my Node.js code on Linux when I work on a Windows machine. This works fine. I also have this bash command so it auto installs my npm modules: bash "install…
Bartvds
  • 3,340
  • 5
  • 30
  • 42
18
votes
1 answer

Redirect stdout and stderr to the same file and restore it

I am redirecting the output of stderr and stdout of my c program to two files and then restoring the original stdout and stderr: int sout = dup(fileno(stdout)); freopen("test.txt","w",stdout); int serr =…
unlimited101
  • 3,653
  • 4
  • 22
  • 41
18
votes
2 answers

how to get stdout into Console.app

Earlier, I could read all stdout/stderr data from applications in Console.app. Since a while, this is not the case anymore (NSLog data is still there, though). I'm on 10.8 now. There was an earlier similar question from 2010 which doesn't seem…
Albert
  • 65,406
  • 61
  • 242
  • 386
18
votes
2 answers

how to print directly to a text file in both python 2.x and 3.x?

Instead of using write(), what are the other way to write to a text file in Python 2 and 3? file = open('filename.txt', 'w') file.write('some text')
Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
17
votes
5 answers

Order of evaluation of arguments using std::cout

Hi all I stumbled upon this piece of code today and I am confused as to what exactly happens and more particular in what order : Code : #include bool foo(double & m) { m = 1.0; return true; } int main() { double test =…
FailedDev
  • 26,680
  • 9
  • 53
  • 73
17
votes
5 answers

how do I write to stdout from an MFC program?

MFC programs can't normally write to stdout. MFC does something weird with the stdout/stdin pipes during startup and anything you write (for example doing a printf("hello");) just goes to /dev/null. Does anyone know how to successfully write to…
Stephen Kellett
  • 3,078
  • 1
  • 22
  • 25
17
votes
3 answers

Spurious newlines added in Django management commands

Running Django v1.10 on Python 3.5.0: from django.core.management.base import BaseCommand class Command(BaseCommand): def handle(self, *args, **options): print('hello ', end='', file=self.stdout) print('world',…
wim
  • 338,267
  • 99
  • 616
  • 750
17
votes
2 answers

Differentiate between error and standard terminal log with ffmpeg - nodejs

I'm using ffmpeg in node js. Both the standard terminal output and the error seems to be sent to stdout, so I don't know how to differentiate between error and success... Here's my code: var convertToMp3 = function(filePath) { var ffmpeg =…
Guig
  • 9,891
  • 7
  • 64
  • 126
17
votes
4 answers

Displaying subprocess output to stdout and redirecting it

I'm running a script via Python's subprocess module. Currently I use: p = subprocess.Popen('/path/to/script', stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = p.communicate() I then print the result to the stdout. This is all fine but as…
asm
  • 837
  • 1
  • 16
  • 41