Unix Programming - Newbie question on writing data to two outputs

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2007 > Newbie question on writing data to two outputs





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Newbie question on writing data to two outputs
philbo30

2007-05-18, 1:18 am

Kind of a C / Linux question all in one; I hope this is the right
group. This is more of an "approach" question than a code question.
System is RH 7.3 with gcc 2.96

Currently I'm redirecting stdout to /dev/ttyS0 with freopen() in order
to write data to a kiosk printer. However, I also need to capture some
of that data so that I can simultaneously write it to a mysql database
immediately after (or immediately before) the ttyS0 output.

One approach is just to run through the full app twice, changing the
output function on the 2nd
run. That sounds way too intensive, so I'm hoping perhaps there's some
sort of "simultaneous" write function. Generally speaking, what's the
best approach to this?

In advance, thanks for a pointer in the write direction.

-P3

philbo30

2007-05-18, 1:18 am

On May 17, 9:55 pm, philbo30 <masfe...@gmail.com> wrote:
> Kind of a C / Linux question all in one; I hope this is the right
> group. This is more of an "approach" question than a code question.
> System is RH 7.3 with gcc 2.96
>
> Currently I'm redirecting stdout to /dev/ttyS0 with freopen() in order
> to write data to a kiosk printer. However, I also need to capture some
> of that data so that I can simultaneously write it to a mysql database
> immediately after (or immediately before) the ttyS0 output.
>
> One approach is just to run through the full app twice, changing the
> output function on the 2nd
> run. That sounds way too intensive, so I'm hoping perhaps there's some
> sort of "simultaneous" write function. Generally speaking, what's the
> best approach to this?
>
> In advance, thanks for a pointer in the write direction.
>
> -P3


Nevermind; solved my problem with fprintf()

Maxim Yegorushkin

2007-05-18, 7:20 am

On 18 May, 02:55, philbo30 <masfe...@gmail.com> wrote:
> Kind of a C / Linux question all in one; I hope this is the right
> group. This is more of an "approach" question than a code question.
> System is RH 7.3 with gcc 2.96
>
> Currently I'm redirecting stdout to /dev/ttyS0 with freopen() in order
> to write data to a kiosk printer. However, I also need to capture some
> of that data so that I can simultaneously write it to a mysql database
> immediately after (or immediately before) the ttyS0 output.
>
> One approach is just to run through the full app twice, changing the
> output function on the 2nd
> run. That sounds way too intensive, so I'm hoping perhaps there's some
> sort of "simultaneous" write function. Generally speaking, what's the
> best approach to this?
>
> In advance, thanks for a pointer in the write direction.


A couple of pointers:
http://www.die.net/doc/linux/man/man1/tee.1.html
http://www.die.net/doc/linux/man/man2/tee.2.html

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com