Questions tagged [stdout]

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

4740 questions
50
votes
6 answers

"subprocess.Popen" - checking for success and errors

I want to check if a subprocess has finished execution successfully or failed. Currently I have come up with a solution but I am not sure if it is correct and reliable. Is it guaranteed that every process outputs its errors only to stderr…
Zingam
  • 4,498
  • 6
  • 28
  • 48
49
votes
4 answers

Making curl send errors to stderr and everything else to stdout

Is there a way to tell curl to output errors to stderr, and everything else to stdout? The reason is that I am using curl from the command line (actually a cronjob) to upload a file to an FTP site every evening. Unfortunately because curl outputs…
Malvineous
  • 25,144
  • 16
  • 116
  • 151
49
votes
3 answers

Scanf/Printf double variable C

Let's say I have this following bit of code in C: double var; scanf("%lf", &var); printf("%lf", var); printf("%f", var); It reads from stdin variable 'var' and then prints twice in stdout 'var'. I understand that's how you read a double variable…
Dragos Rizescu
  • 3,380
  • 5
  • 31
  • 42
48
votes
5 answers

How do I redirect stderr and stdout to file for a Ruby script?

How do I redirect stderr and stdout to file for a Ruby script?
AOO
  • 481
  • 1
  • 4
  • 3
47
votes
10 answers

How do I get 'real-time' information back from a subprocess.Popen in python (2.5)

I'd like to use the subprocess module in the following way: create a new process that potentially takes a long time to execute. capture stdout (or stderr, or potentially both, either together or separately) Process data from the subprocess as it…
Ryan
  • 4,179
  • 6
  • 30
  • 31
47
votes
5 answers

How to turn off buffering of stdout in C

I want to turn off the buffering for the stdout for getting the exact result for the following code while(1) { printf("."); sleep(1); } The code printf bunch of '.' only when buffer gets filled.
Sreenath Nannat
  • 1,949
  • 1
  • 13
  • 18
47
votes
2 answers

PHP: How to use monolog to log to console (php://out)?

I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on…
Hirnhamster
  • 7,101
  • 8
  • 43
  • 73
46
votes
8 answers

How can a process intercept stdout and stderr of another process on Linux?

I have some scripts that ought to have stopped running but hang around forever. Is there some way I can figure out what they're writing to STDOUT and STDERR in a readable way? I tried, for example, to do: $ tail -f /proc/(pid)/fd/1 but that…
Thomas Vander Stichele
  • 36,043
  • 14
  • 56
  • 60
46
votes
4 answers

Running powershell script within python script, how to make python print the powershell output while it is running

I am writing a python script which checks various conditions and runs a powershell script accordingly to help me automate migration from windows XP to windows 7. The powershell script gives its own output giving the user updates as to what is…
user3282276
  • 3,674
  • 8
  • 32
  • 48
46
votes
5 answers

Run Java class file from PHP script on a website

I have a website and want to be able to allow the user to run a Java file on the server from the website. I want the user to click a button which will run the Java file on the server AND anything printed to standard-out by the Java program will be…
tree-hacker
  • 5,351
  • 9
  • 38
  • 39
46
votes
2 answers

Suppressing output in python subprocess call

For the following command: subprocess.call(shlex.split( """/usr/local/itms/bin/iTMSTransporter -m lookupMetadata -apple_id %s -destination %s"""%(self.apple_id, self.destination)) It prints the entire output into the…
David542
  • 104,438
  • 178
  • 489
  • 842
43
votes
3 answers

How to detect if the console does support ANSI escape codes in Python?

In order to detect if console, correctly sys.stderr or sys.stdout, I was doing the following test: if hasattr(sys.stderr, "isatty") and sys.stderr.isatty(): if platform.system()=='Windows': # win code (ANSI not supported but there are…
sorin
  • 161,544
  • 178
  • 535
  • 806
42
votes
2 answers

Writing a pytest function for checking the output on console (stdout)

This link gives a description how to use pytest for capturing console outputs. I tried on this following simple code, but I get error import sys import pytest def f(name): print "hello "+ name def test_add(capsys): f("Tom") …
brain storm
  • 30,124
  • 69
  • 225
  • 393
41
votes
6 answers

Redirect echo output in shell script to logfile

I have a shell script with lots of echo in it. I would like to redirect the output to a logfile. I know there is the command call cmd > logfile.txt, or to do it in the file echo 'xy' > logfile.txt, but is it possible to simply set the filename in…
wasp256
  • 5,943
  • 12
  • 72
  • 119
39
votes
6 answers

multiprocessing: How can I ʀᴇʟɪᴀʙʟʏ redirect stdout from a child process?

NB. I have seen Log output of multiprocessing.Process - unfortunately, it doesn't answer this question. I am creating a child process (on windows) via multiprocessing. I want all of the child process's stdout and stderr output to be redirected to a…
Tom
  • 1,204
  • 2
  • 10
  • 25