stdout

How to save the output of a console application

I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I would like to implement is to dump the entire output buffer to a text file at the end of program execution. The workaround I use while I don't find a cleaner approach...

How best to draw in the console?

I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game. I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and printing it. However that me...

Python output buffering

Is output buffering enabled by default in Python's interpreter for sys.stdout ? If the answer is positive, what are all the ways to disable it ? Suggestions so far: Use the -u command line switch Wrap sys.stdout in an object that flushes after every write Set PYTHONUNBUFFERED env var sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', ...

How do you capture stderr, stdout, and the exit code all at once, in Perl?

Is it possible to run an external process from Perl, capture its stderr, stdout AND the process exit code? I seem to be able to do combinations of these, e.g. use backticks to get stdout, IPC::Open3 to capture outputs, and system() to get exit codes. How do you capture stderr, stdout, and the exit code all at once? ...

Best way to capture stdout from a system() command so it can be passed to another function

I'm trying to start an external application through system() - for example system("ls") - i would like to capture it's output as it happens so i can send it to another function for further processing. What's the best way to do that in C/C++ ? ...

Can an Adobe AIR Application run via the command line output to console?

I have an AIR application that takes command-line arguments via onInvoke. All is good, but I cannot figure out how to print some status messages back to the user (to stdout / console, so to speak). Is it possible? Even a default log file for traces would be fine, but I can't find any info about it anywhere. Do I need to create my own lo...

Redirect Stdin and Stdout to File

I'm currently the Teaching Assistant for an Introduction to C class. The class is being taught using Visual Studio, but when grading I just use a simple Windows batch script to process all the assignment submissions, compile them, run them on a test file, and redirect the output to a series of text files I can print out, mark up, and han...

RedirectStandardOutput is buffering lines instead of being instantaneous?

Ok, I am trying to use Tail to monitor a log file, but I cannot get the same behavior programatically as when I manually run it through cmd prompt using the same parameters. When run through cmd prompt it displays the new lines instantly. Programatically though, I have to wait for about 75+ new lines in log file before the 'buffer' unle...

Removing first line from stdin and redirect to stdout

i need to redirect all of the stdout of a program except the first line into a file. Is there a common unix program that removes lines from stdin and spits the rest out to stdout? ...

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 for ever. 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 doesn't really work. It was a long shot anyway. Any other ideas ? strace on its own is quite...

Windows API colored output to stdout in Powershell/cmd.exe

Anyone know where to find a reference that describes how to output color on the Windows CLI interfaces using API and/or stdout? ...

sleep() is stalling my program too early. What am I doing wrong?

I want to write a small program that should print something like testing CPU... done testing RAM... done and so on. I wrote the following program in C: printf( "testing RAM...\t\t" ); sleep( sleep_time ); printf( "done\n\n" ); printf( "testing HDD...\t\t" ); sleep( sleep_time ); printf( "done\n\n" ); where sleep_time i...

How do I redirect terminal output from a C program to System.out with JNI?

I am invoking a C library via JNI that prints to stdout. How can I redirect this output to System.out? ...

launch app, capture stdout and stderr in c++

How do I launch an app and capture the output via stdout and maybe stderr? I am writing an automated build system and I need to capture the output to analyze. I'd like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build using make and upload the co...

Redirect stout from child process with .net

I'm using the following code System::Diagnostics::Process^ p = gcnew System::Diagnostics::Process(); p->StartInfo->FileName = "tnccmd.exe"; p->StartInfo->UseShellExecute = false; p->StartInfo->RedirectStandardInput = true; p->StartInfo->RedirectStandardOutput = true; p->Start(); System::IO::StreamWriter^ tnc_stdin = p->StandardInput; ...

Java: Run a Callable in a separate process

Given an instance x of Callable<T>, how can I run x in a separate process such that I can redirect the standard input and output of the process? For example, is there a way to build a Process from a Callable? Is there a standard Executor that gives control over input and output? [UPDATE] It's not important that the Callable execute in a...

printf("something\n") outputs "something " (additional space) (g++/linux/reading output file with gedit)

I have a simple C++ program that reads stdin using scanf and returns results to stdout using printf: #include <iostream> using namespace std; int main() { int n, x; int f=0, s=0, t=0; scanf("%d", scanf("%d", for(int index=0; index<n; index++) { scanf("%d", scanf("%d", scanf("%d", ...

Python FastCGI under IIS - stdout writing problems

Hello all, I'm having a very peculiar problem in my Python FastCGI code - sys.stdout has a file descriptor of '-1', so I can't write to it. I'm checking this at the first line of my program, so I know it's not any of my code changing it. I've tried sys.stdout = os.fdopen(1, 'w'), but anything written there won't get to my browser. The...

Changing the value of stdout in a C++ program

I have a Windows C++ program that is doing something like: FILE* pf = ...; *stdout = *pf; // stdout is defined in stdio.h I'm looking for an explanation about what happens when you change the value of the stdout file handle. Is this just a way of redirecting stdout? -cr ...

console output formatting.

Are there any conventions for formatting console output from a command line app for readability and consistency? For instance, do you indent sub-information, when do you print a blank line, if ever, how should you accent important statements. I've found output can quickly degenerate into a chaotic blur. I'm interested in hearing abou...