Hi John,

You could add an option "-O" to your application, if that is specified
you write everything to stdout and the last positional parameter can be
omitted.

The "tar" command has such an option:

       -O, --to-stdout
              extract files to standard output

So you could so something like:

        FILE *fh;

        if (stderr_specified)
                fh = stderr;
        else
                fh = fopen(file_out, ...


Michael


On Wed, 2009-12-02 at 11:16 -0600, McKown, John wrote:
> > -----Original Message-----
> > From: Linux on 390 Port [mailto:[email protected]] On
> > Behalf Of Rich Smrcina
> > Sent: Wednesday, December 02, 2009 10:48 AM
> > To: [email protected]
> > Subject: Re: Linux software development question
> >
> > stderr is filehandle 2.  To redirect it to a file use 2> on
> > the command
> > line:
> >
> > $ command <filein >fileout 2>errout
> >
>
> I must have said what I want to do exactly backwards. I don't want to direct 
> stderr to a file. I want to tell an application to output to /dev/fd/2 
> instead of to a file. Well, hell, that's how to do it! In my application, the 
> last file name in the parameter list is the output file name. So it cannot be 
> omitted.
>
> app in1 in2 in3 output.file
>
> would become
>
> app in1 in2 in3 /dev/fd/2
>
> and I could do an fopen() on that, or just detect that as my convention and 
> use file descriptor 3 directly. Stick me with a fork, I'm done!
>
> --
> John McKown
> Systems Engineer IV
> IT
>
> Administrative Services Group
>
> HealthMarkets(r)
>
> 9151 Boulevard 26 * N. Richland Hills * TX 76010
> (817) 255-3225 phone * (817)-961-6183 cell
> [email protected] * www.HealthMarkets.com
>
> Confidentiality Notice: This e-mail message may contain confidential or 
> proprietary information. If you are not the intended recipient, please 
> contact the sender by reply e-mail and destroy all copies of the original 
> message. HealthMarkets(r) is the brand name for products underwritten and 
> issued by the insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake 
> Life Insurance Company(r), Mid-West National Life Insurance Company of 
> TennesseeSM and The MEGA Life and Health Insurance Company.SM
>
>
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO LINUX-390 or visit
> http://www.marist.edu/htbin/wlvindex?LINUX-390

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to