stdout

What is the best way to redirect stdout to NSTextView in Cocoa?

Hi: I want to redirect stdout to a NSTextView. Could this also work with outputs of subprocesses? What might be the best way to achieve this? EDIT: According to Peter Hosey answer I implemented the following. But I do not get a notification. What am I doing wrong? NSPipe *pipe = [NSPipe pipe]; NSFileHandle *pipeHandle = [pipe f...

Bash+cron: Redirecting, and restoring, stdout and stderr produces permission denied

I've got a script that calls out to a bunch of commands, some of which are noisy to stdout, some to stderr, some to both. I intend the script to be run by cron, so I don't want it to be noisy and mail me every day -- only in error conditions. So I do: be_quiet() { # save stderr in FD 3 exec 3>&2 exec &> /dev/null } die() { ...

bash: redirect (and append) stdout and stderr to file and terminal

To redirect (and append) stdout and stderr to a file, while also displaying it on the terminal I do this: command 2>&1 | tee -a file.txt However, is there another way to do this such that I get an accurate value for the exit status? That is if I test $?, I want to see the exit status of 'command' and not the exit status of tee. I kn...

Standard Buffer not getting cleared before system() call

#include<stdio.h> #include<signal.h> #include<stdlib.h> void handler(int signo) { printf("First statement"); system("date"); exit(EXIT_SUCCESS); } int main() { signal(SIGINT,handler); printf("Waiting for KeyboardInterrupt\n"); for(;;); return 0; } Test run:- shadyabhi@shadyabhi-desktop:~/c$ gcc main.c shad...

redirect stdout and stderr to a single file with prefixes

I am writing a bash script and need to redirect the stdout and stderr output of a command i run to a single file, prefixing each line with stderr or stdout, accordingly. is there a simple way to do this? ...

Printing Stdout In Command Line App Without Overwriting Pending User Input

In a basic Unix-shell app, how would you print to stdout without disturbing any pending user input. e.g. Below is a simple Python app that echos user input. A thread running in the background prints a counter every 1 second. import threading, time class MyThread( threading.Thread ): running = False def run(self): self....

How can I run an external command and capture its output in Perl?

I'm new to Perl and want to know of a way to run an external command (call it prg) in the following scenarios: Run prg, get its stdout only. Run prg, get its stderr only. Run prg, get its stdout and stderr, separately. ...

Pipe ffmpeg to oggenc(2) with .NET

I am trying to encode ogg files at -q 6/192k. ffmpeg doesnt seem to be listenting to my command ffmpeg -i blah -acodec vorbis -ab 192k -y out.ogg So i would like to use the recommended ogg encoder. It says the input must be wav or similar. I would like to pipe a wav from ffmpeg to ogg. However not only am i unsure if oggenc2 will acc...

C++ print value of a pointer

I have an array of double pointers, but every time I try do print one of the values the address gets printed. How do I print the actual value? cout << arr[i] ? cout << &arr[i] ? they both print the address Does anyone know? ...

C++ alignment when printing cout <<

Is there a way to align text when priting using cout? I'm using tabs, but when the words are too big they won't be aligned anymore Sales Report for September 15, 2010 Artist Title Price Genre Disc Sale Tax Cash Merle Blue 12.99 Country 4% 12.47 1.01 13.48 Richard Music 8.49 Classical 8% 7.81 0.66 ...

Strange behaviour with fputs and a loop.

When running the following code I get no output but I cannot work out why. # include <stdio.h> int main() { fputs("hello", stdout); while (1); return 0; } Without the while loop it works perfectly but as soon as I add it in I get no output. Surely it should output before starting the loop? Is it just on my system? Do I...

How do i pipe stdout/stderr in .NET?

I want to do something like this ffmpeg -i audio.mp3 -f flac - | oggenc2.exe - -o audio.ogg i know how to do ffmpeg -i audio.mp3 -f flac using the process class in .NET but how do i pipe it to oggenc2? Any example of how to do this (it doesnt need to be ffmpeg or oggenc2) would be fine. ...

Windows console

Hello. Well, I have a simple question, at least I hope its simple. I was interested in win32 console for a while. Our teacher told us, that windows console is just for DOS and real mode emulation purposes. Well, I know it is not true, becouse DOS applications are runned by emulator which only uses console to display output. Another thing...

Cheat sheet exhibiting bash shell stdout/stderr redirection behavior

Is there a good cheat sheet demonstrating the many uses of BASH shell redirection? I would love to give such a thing to my students. Some examples I'd like to see covered: cmd > output_file.txt #redirect stdout to output_file.txt cmd 2> output_file.txt #redirect stderr to output_file.txt cmd >& outpout_file.txt #redirec...

C stdout printf problem

I have a weird issue with printing data out. I use printf to print a char* string and then after that print another one. However part of the first string doesn't get printed and when I print the second string the missing part of the first one is pretended to that one. What is happening here? I'm writting a simple libpcap implimentatio...

Delphi - Capture stdout and stderr output from statically linked MSVC++ compiled DLL

I have been trying to capture stdout and stderr output from a DLL compiled in MSVC++ that my Delphi app statically links to, but so far have been unsuccessful. procedure Test; var fs: TFileStream; begin fs := TFileStream.Create('C:\temp\output.log', fmCreate or fmShareDenyWrite); SetStdHandle(STD_OUTPUT_HANDLE, fs.Handle); SetS...

Put `stdout` in an `NSTextView` while running the a command

I'm creating a Cocoa Application, which will need to run the rails command. This command generates an output, and streams it to stdout. I want to show this output to the user in an NSTextView (so basicly stream the stdout to the NSTextView). My application should not 'hang' when the command is running (e.g. the git command takes a long t...

Send JVM -verbose output to stderr instead of stdout

I'm running java with the -verbose:gc option to measure garbage collector behavior, but it sends the info to stdout, mixing with my program's normal output. How do I tell it to output this info to stderr? ...

Redirecting multiple stdouts to single file

I have a program running on multiple machines with NFS and I'd like to log all their outputs into a single file. Can I just run ./my_program >> filename on every machine or is there an issue with concurrency I should be aware of? Since I'm only appending, I don't think there would be a problem, but I'm just trying to make sure. ...

Bourne Script: Redirect success messages but NOT error messages

This command: keytool -import -file "$serverPath/$serverCer" -alias "$clientTrustedCerAlias" -keystore "$clientPath/$clientKeystore" -storepass "$serverPassword" -noprompt Will when it runs successfully outputs: Certificate was added to keystore I tried redirecting the stdard out with: keytool ... > /dev/null But it is still prin...