io-redirection

When pipes are in place and have overwritten stdout and stderr, where does printf go?

I have set up pipes to redirect stderr and stdout. When I use printf, does it send data to stdout or to stream 1? If it sends it to stdout, how can I instead configure it to send data to stream 1? ...

I/O redirection in eclipse?

Hi, Is it possible to use IO redirection in eclipse? I want to redirect standard input/output on the command line like java MyProgram <input.txt >output.txt, but I can't seem to get it to work in eclipse. I tried including the <'s as part of the program arguments, which was ignored, and also in the VM arguments, which just threw up a cl...

bash - redirecting of stdoutput and stderror does not catch all output

I am writing some testing scripts and want to catch all error output and write it to an error log as well as all regular output and write that to a separate log. I am using a command of the form cmd > output.file 2> error.file The command I am writing test scripts for can cause a segmentation fault. When the command segfaults, bash s...

Details of redirection in bash (Cygwin specifically)

I'm wondering if anyone can point me at resources dealing with the low(ish) level mechanics of how output rediction works in bash. Unfortunately, I've only been able to turn up pages and pages of the basic "> sends output to a file" guides, but nothing seems to go into more detail than that. In particular, I'm facing a strange situatio...

BASH: error message does not get redirected to file

I have a bash script that simply calls different calls and redirect stdout and stderr outputs to different files. I've done this: command 1> datafile 2>> errorfile However, when the command is erroneous (e.g. wrong username and password combination given as arguments), the error message does not get redirected to the errorfile. I sti...

understanding shell redirection on non existant files

ls > ls.out this will include ls.out in the list too. My understanding is: > (shell output redirection operator is creating a file first (to take the STDOUT) if it is not already existing and then ls command is coming to play and it is including the just created ls.out file in the output. Is this correct? If not, can you please elab...

Redirect Embedded Python IO to a console created with AllocConsole

I am having some trouble getting Python IO redirected to a console that I've allocated for my Win32 app. Is there a Python-specific stream that I need to redirect? Here's more-or-less what I'm doing now (error checking removed, etc.): int __stdcall WinMain(/*Usual stuff here*/) { // Create the console AllocConsole(); SetCon...

In C how do I print filename of file that is redirected as input in shell

$cc a.c $./a.out < inpfilename I want to print inpfilename on stdout. How do I do that ? Thanks for the help in advance... ...

what argument i can give when execute unix executable

It just occur to me that following command can print output in text file. ./a.out < infile.txt > actualoutput.txt But i still wondering what < infile.txt > is for? And what other arguments i can give when executing this object file? ...

Separate standard output from standard error when running a program in eclipse

I am debugging a Java program in eclipse. This program normally writes binary data to its standard output but can write error messages & stack traces to its standard error stream. I would like to redirect the binary data to a file, while continuing to show the standard error output in a console. This is trivial when running from the c...

Bash: redirect standard input dynamically in a script

I was trying to do this to decide whether to redirect stdin to a file or not: [ ...some condition here... ] && input=$fileName || input="&0" ./myScript < $input But that doesn't work because when the variable $input is "&0", bash interprets it as a filename. However, I could just do: if [ ...condition... ];then ./myScript <$file...

Why doesn't cl.exe generate any output when I call it from Perl?

I'm having a weird problem with running cl.exe that has me stumped. In a large VS2008 solution consisting of C/C++ projects, I have one project that runs some scripts to do some extra processing. The project consists of a pre-build event, which calls a Perl script (ActiveState Perl is on the machine). This Perl script then calls cl.ex...

Cross-platform redirect of standard input and output of spawned process in native C/C++ (edit with solution)

Hello, I have a string command I'd like to execute asynchronously while writing to its input and reading its output. Sounds easy, right, the devil is in the cross-platform. I'm targeting both MSVC/Win32 and gcc/Linux and obviously want to write the minimum amount of platform-specific code. My google-fu has failed me, I get too much nois...

wget to memory (bypassing disk)

Is it possible to download contents of a website (a set of html pages) straight to memory without writing to disk? I have a cluster of machines with 24G ram each, but I'm limited by a disk quota to several hundreds MB. I was thinking of redirecting the output of wget command for example to some kind of in-memory structure without storing...

The '<' operator is reserved for future use (PowerShell)

I am using powershell and am trying to run the following command: .\test_cfdp.exe < test.full | tee test.log test.full is a script that mimics command line inputs to test_cfdp.exe. However, I get the following error: The '<' operator is reserved for future use. Is there another way (i.e. cmdlet) I can use to get this command to wo...

How do I capture all of my compiler's output to a file?

Hello, I'm building an opensource project from source (CPP) in Linux. This is the order: $CFLAGS="-g Wall" CXXFLAGS="-g Wall" ../trunk/configure --prefix=/somepath/ --host=i386-pc --target=i386-pc $make While compiling I'm getting lot of compiler warnings. I want to start fixing them. My question is how to capture all the compiler o...

How to view some data in gvim without saving it first?

For example suppose I do a certain man or maybe a grep. I want to see the results using gvim without the normal procedure of saving them first and opening the saved file [because I don't need the results once I view them] I tried two ways, both the methods fail: a) man gcc | gvim //opens a blank gvim window b) man gcc > gvim //sa...

Unable to capture standard output of process using Boost.Process

Currently am using Boost.Process from the Boost sandbox, and am having issues getting it to capture my standard output properly; wondering if someone can give me a second pair of eyeballs into what I might be doing wrong. I'm trying to take thumbnails out of RAW camera images using DCRAW (latest version), and capture them for conversi...

How to do proper Unicode and ANSI output redirection on cmd.exe?

If you are doing automation on windows and you are redirecting the output of different commands (internal cmd.exe or external, you'll discover that your log files contains combined Unicode and ANSI output (meaning that they are invalid and will not load well in viewers/editors). Is it is possible to make cmd.exe work with UTF-8? This qu...

How can I redirect the output of Perl's system() to a filehandle?

With the open command in Perl, you can use a filehandle. However I have trouble getting back the exit code with the open command in Perl. With the system command in Perl, I can get back the exit code of the program I'm running. However I want to just redirect the STDOUT to some filehandle (no stderr). My stdout is going to be a line-by...