stdout

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 Visual Studio (specifically Visual C# Express 2008). Is there a way to do that? (Additiona...

In Scala or Java, how to print a line to console replacing its previous content instead of appending?

A Scala application does some data processing. It would be nice to show processing progress in percents overwriting previous value on change rather than appending a new value to what's already displayed. How to acheive this effect? I use Scala 2.8 on Linux. ...

Writing to both stdout & a file

I have a parent process which forks out a child to perform execv(). I need the output given by execv() to stdout to be displayed onscreen as also copied to a log file. How do I write the same output to both stdout & a file, without using pipes or tees? ...

Redirecting in C++

#include <iostream> #include <fstream> using namespace std; void foo(){ streambuf *psbuf; ofstream filestr; filestr.open ("test.txt"); psbuf = filestr.rdbuf(); cout.rdbuf(psbuf); } int main () { foo(); cout << "This is written to the file"; return 0; } Does cout write to the given file? If not, is there a way t...

Knowing class loading and unloading in tomcat

I am specifying the below command in catalina.bat > set JAVA_OPTS=-XX:+TraceClassLoading -XX:+TraceClassUnloading -XX:+PrintGCDetails The logs are printed in console but i am not able to redirect the logs in file. Using startup.bat > logs.txt Can anyone tell me how to save/trace the console logs?? ...

Python stdout doesn't flush correctly after calling curses.

I have a program that uses curses, and then returns to the main script for further processing. After it returns, my subsequent output to stdout does not appear until there's a large amount of it (e.g. thousands of bytes). I've reduced the problem to a very simple program that fails reliably: import curses import time curses.initscr() ...

Python: Setting sys.stdout to a wx.TextCtrl with Process/Thread leads to crashes

I've got a wx-gui that's piping stdout/stderr to two different text-controls. In the program I'm creating a process to run some data-crunching code, and I have a thread that joins the process and changes the global state when the process is finished. import multiprocessing as mp from threading import Thread t = Thread(target=self.joi...

Is stdout line buffered, unbuffered or indeterminate by default?

Section 7.9.13/7 of c99 states that: At program start-up, three text streams are predefined and need not be opened explicitly - standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output). As initially opened, the standard error stream is ...

How do I avoid printing to STDOUT when using Perl's `IPC::System::Simple:runx`?

I'm using IPC::System::Simple:runx to execute system commands and die on unexpected return values. The problem is that the commands output is printed to the shell. How can I avoid printing this output? How can I avoid printing this output but getting it into a perl variable? UPDATE 3) How can I print this output iff the execution fa...

cl.exe (MS Visual C++) seem to wrongly send compile tome errors to stdout instead of stderr

It seems as if cl.exe would wrongly send the compiler errors to stdout instead of stderr. This behavior seems to be a bug and the only workaround (I could think of) it to redirect stderr and stdout but this makes is impossible to monitor the compile progress. Is this a bug? Are there any workarounds? ...

How to remove last character put to std::cout?

Is it possible on Windows without using WinAPI? ...

Redirect stdout to Visual Studio output window from native c++ dll

I have a c# windows app that calls a managed c++ dll, which, in turn, calls a native c++ dll. There seem to be some performance issues in the native c++ code, so I'm doing some simple profiling. I'd like to dump the results of the profiling so that the Visual Studio output window picks it up. I thought that printf would do the trick, but...

how do i check stdin has some data?

in python,how to check sys.stdin has data or not, i found os.isatty(0) only can check is connect to a tty device,but if some one use code like sys.stdin=cStringIO.StringIO("ddd") after that use os.isatty(0) it's still return True, what i need is check from stdin is have data,any advice is welcome ...

How do I send multi-line output from Perl to /bin/mail?

I have a Perl script that prints multiple lines of output to screen. I need to capture those lines and either pipe them into a single piece of email ( /bin/mail ) or into a text file that I can send by /bin mail in another operation. Actually, I have already figured out the easy (dumb) way whereby I use a bash wrapper to do the mailing b...

How do you stream data into the STDIN of a program from different local/remote processes in Python?

Standard streams are associated with a program. So, suppose there is a program already running in some way (I don't care how or in what way). The goal is to create pipes to the STDIN of the program from different processes (or programs) that run either locally or remotely and stream data into it asynchronously. Available information is ...

How to capture stdout/stderr with googletest?

Is it possible to capture the stdout and stderr when using the googletest framework? For example, I would like to call a function that writes errors to the console (stderr). Now, when calling the function in the tests, I want to assert that no output appears there. Or, maybe I want to test the error behaviour and want to assert that a ...

python, subprocess: reading output from subprocess

I have following script: #!/usr/bin/python while True: x = raw_input() print x[::-1] I am calling it from ipython: In [5]: p = Popen('./script.py', stdin=PIPE) In [6]: p.stdin.write('abc\n') cba and it works fine. However, when I do this: In [7]: p = Popen('./script.py', stdin=PIPE, stdout=PIPE) In [8]: p.stdin.write('...

Inspect stdout from the middle of chained apps

Consider this example chain: cat foo.txt | grep -v foo | grep -v bar | grep -v baz I'd like to inspect the contents stdout of the second grep as well as the resulting stdout: cat foo.txt | grep -v foo | grep -v bar | UNKNOWN | grep -v baz So I need a tool, UNKNOWN, that for instance dumps the contents of stdout to a file and also p...

Redirecting forked process output to parent process in C

What I am implementing is a (simpler) version of bash. One of the tasks is to accept the command : $ bg <command> <arguments> This will then fork a new process and then run execvp() in the new process using <command> and <arguments> as parameters. The problem is that when I capture the output from the child process, I use pipe(), an...

How to log STDOUT of a background process w/o buffering on Mac?

I am running a background process on Mac and have a problem with log update. If I run someprog > mylog & then mylog is updated not immediately, but with some intervals - I guess it's due to buffering. Same thing with at now. If I kill the program before output is written to mylog, then I loose the data. There was no such problem with ...