Questions tagged [stdout]

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

4740 questions
16
votes
2 answers

Why does the print to stdout not happen when using fprintf?

I have this code: #include #include int main() { while(1) { fprintf(stdout,"hello-out"); fprintf(stderr,"hello-err"); sleep(1); } return 0; } The…
insane
  • 729
  • 1
  • 7
  • 17
16
votes
5 answers

'app --help' should go to stdout or stderr?

I think stdout, so you can easily grep, what do you think?
stacky
15
votes
2 answers

Why would I need use fflush on stdout before writing to stderr?

I am reading 'UNIX Network Programming: The Sockets Networking API' and in the example code they have an error handling function which contains the following lines: fflush(stdout); /* in case stdout and stderr are the same */ fputs(buf,…
dippynark
  • 2,743
  • 20
  • 58
15
votes
1 answer

Where do writes to stdout go when launched from a cygwin shell, no redirection

I have an application, let's call it myapp.exe, which is dual-mode console/GUI, built as /SUBSYSTEM:WINDOWS (There's a tiny 3KB shim myapp.com to cause cmd.exe to wait to display the new prompt.) If I launch from a command prompt: myapp -> cmd.exe…
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
15
votes
5 answers

How can I read process output that has not been flushed?

Consider this little programm be compiled as application.exe #include int main() { char str[100]; printf ("Hello, please type something\n"); scanf("%[^\n]s", &str); printf("you typed: %s\n", str); return 0; } Now I…
ArcticLord
  • 3,999
  • 3
  • 27
  • 47
15
votes
1 answer

python - prevent IOError: [Errno 5] Input/output error when running without stdout

I have a script that runs automatically on server through cronjob and it import and run several other scripts. Some of them use prints, which naturally creates IOError: [Errno 5] Input/output error because the script runs without any SSH / terminal…
Ronen Ness
  • 9,923
  • 4
  • 33
  • 50
15
votes
4 answers

Redirect the output (stdout, stderr) of a child process to the Output window in Visual Studio

At the moment I am starting a batch file from my C# program with: System.Diagnostics.Process.Start(@"DoSomeStuff.bat"); What I would like to be able to do is redirect the output (stdout and stderr) of that child process to the Output window in…
Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
15
votes
1 answer

Print LF with Python 3 to Windows stdout

How to get \n printed to stdout on Windows? This code works in Python 2, but not with Python 3: # set sys.stdout to binary mode on Windows import sys, os, msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) # the length of testfile created…
anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140
15
votes
1 answer

How to change how frequently SLURM updates the output file (stdout)?

I am using SLURM to dispatch jobs on a supercomputer. I have set the --output=log.out option to place the content from a job's stdout into a file (log.out). I'm finding that the file is updated every 30-60 minutes, making it difficult for me to…
Neal Kruis
  • 2,055
  • 3
  • 26
  • 49
15
votes
1 answer

Node.js: child_process.spawn no output standard output unless 'inherit'

I'm trying to capture standard output from a spawned child_process in Node.js (0.10.29). Right now I'm just trying with ping. The following code doesn't print (but does ping) var exec = require('child_process').exec; var spawn =…
dbenny
  • 151
  • 1
  • 3
15
votes
4 answers

using Python 'with' statement with sys.stdout

I always open and write into files using with statement: with open('file_path', 'w') as handle: print >>handle, my_stuff However, there is one instance where I need to be able to be more flexible, and write to sys.stdout (or other types of…
farmir
  • 1,259
  • 1
  • 10
  • 14
15
votes
2 answers

Python. Redirect stdout to a socket

I run my script on computer "A". Then I connect to computer "A" from computer "B" through my script. I send my message to computer "A" and my script runs it with an exec() instruction. I want to see the result of executing my message on computer…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
15
votes
8 answers

Can I send STDOUT and STDERR to a log file and also to the screen in Win32 Perl?

I've searched the Internet and have found some good solutions for teeing STDOUT to 2 different places. Like to a log file and also to the screen at the same time. Here's one example: use IO::Tee; my $log_filename = "log.txt"; my…
Kurt W. Leucht
  • 4,725
  • 8
  • 33
  • 45
15
votes
2 answers

Pipe to multiple files, but not stdout

I want to pipe stdout to multiple files, but keep stdout itself quiet. tee is close but it prints to both the files and stdout $ echo 'hello world' | tee aa bb cc hello world This works but I would prefer something simpler if possible $ echo 'hello…
Zombo
  • 1
  • 62
  • 391
  • 407
15
votes
3 answers

Python Popen().stdout.read() hang

I'm trying to get output of another script, using Python's subprocess.Popen like follows process = Popen(command, stdout=PIPE, shell=True) exitcode = process.wait() output = process.stdout.read() # hangs here It hangs at the third line, only when…
lyomi
  • 4,230
  • 6
  • 30
  • 39