Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting Real-Time stdin data using Pipe

2 views
Skip to first unread message

Mike K

unread,
May 26, 2002, 12:45:46 AM5/26/02
to
Hello all,

I have a program, call it Streamer.exe that streams important real-time data
to the screen.
I've written a program, call it Parser.exe, that expects to read in the data
produced by Streamer, and produce real-time analysis and statistics about
it, which I want put on the screen instead of the garbage code that Streamer
writes.
I've therefore run it as:
C:\> Streamer.exe | Parser.exe
Unfortunately, it seems that the '|' pipe character only sends the data to
Parser after Streamer has finished running. This is not what I'm looking
for, I want to get the data as it's coming out of Streamer, and have Parser
write it to the screen!
Maybe using the pipe isn't the best way to do this? Perhaps using one of the
spawn() varieties from <stdio> or <process> would be better? I'm not
familiar with the spawning, so if someone could help me out with how they
work, that would be great.
I'm writing this in C/C++ using Borland's Turbo C++ v1.01 on a Pentium
system running MS-DOS v6.22.
Please help!

Thanks!

Mike
mki...@rogers.com


Mike K

unread,
May 26, 2002, 12:47:28 AM5/26/02
to
Scratch the spawn part, I believe that's only for Win95/NT.

Mike


Charles Angelich

unread,
May 26, 2002, 3:09:42 AM5/26/02
to

Wrong spawn() is available for DOS C code.

>Scratch the spawn part, I believe that's only for Win95/NT.
>
>Mike
>
>

--
Take Care -
>
> __
> | / \ \ USA, MI // \\
> \_\\ //_/ Crawling on The Web _\\()//_
> .'/()\'. Charles Angelich / // \\ \
> \\ // | \__/ |
> www.undercoverdesign.com/dosghost
>

Charles Angelich

unread,
May 26, 2002, 3:12:46 AM5/26/02
to

Short version: Parser cannot `see' buffers used by Streamer unless
you combine the two programs into one. Alternately if you used a
multitasker like Desqview you could have an inter-process memory
area defined and semaphore flags to indicate that the buffer was
ready to be `emptied'. Hardly worth doing IMO.

Combining the two programs would be the most effective solution.

--

Herman Dullink

unread,
May 26, 2002, 4:42:06 AM5/26/02
to
Hi,

>I have a program, call it Streamer.exe that streams important real-time
data
>to the screen.

<snip>


>I've therefore run it as:
>C:\> Streamer.exe | Parser.exe
>Unfortunately, it seems that the '|' pipe character only sends the data to
>Parser after Streamer has finished running.

Yes, DOS is a single task OS, so it can only run one program until finished.
DOS will put the streamer output in a temporary file, and then use
that for the parser input.

>Perhaps using one of the
>spawn() varieties from <stdio> or <process> would be better?

Because single tasking, spawn will be very similar to exec, ie it will
run the other program until finished, then continue with current one.

H

Mike K

unread,
May 26, 2002, 8:52:25 AM5/26/02
to
This would be much easier to do had I written Streamer.exe. But I don't have
the source to it, and this was my next-best solution.
Oh well, I guess it can't be done in DOS... Time to move to UNIX...

Mike


"Charles Angelich" <charles_...@hotmail.com> wrote in message
news:acq1td$r940v$3...@ID-128113.news.dfncis.de...

Kenneth Brody

unread,
May 26, 2002, 2:31:53 PM5/26/02
to
Mike K wrote:
>
> Hello all,
>
> I have a program, call it Streamer.exe that streams important real-time data
> to the screen.
> I've written a program, call it Parser.exe, that expects to read in the data
> produced by Streamer, and produce real-time analysis and statistics about
> it, which I want put on the screen instead of the garbage code that Streamer
> writes.
> I've therefore run it as:
> C:\> Streamer.exe | Parser.exe
> Unfortunately, it seems that the '|' pipe character only sends the data to
> Parser after Streamer has finished running. This is not what I'm looking
> for, I want to get the data as it's coming out of Streamer, and have Parser
> write it to the screen!
[...]

The short answer is "you can't", at least not under straight DOS.

Welcome to the single-tasking world of DOS. DOS emulates pipes by sending
stdout of the first program to a disk file, runs it to completion, and
then runs the next program with its stdin redirected from that same file.

You could, if you felt up to the task, rewrite streamer do act as an
interrupt-driven TSR, stuffing its output into the keyboard buffer. Or,
rewrite both programs to run under some DOS-based multitasker, and have
them communicate via some interprocess communication.

Short of that, get a version that runs on a multitasking system, such
as Unix or Linux.

--

+---------+----------------------------------+-----------------------------+
| Kenneth | kenbrody at spamcop.net | "The opinions expressed |
| J. | http://www.hvcomputer.com | herein are not necessarily |
| Brody | http://www.fptech.com | those of fP Technologies." |
+---------+----------------------------------+-----------------------------+

Paul Schlyter

unread,
May 26, 2002, 4:19:43 PM5/26/02
to
In article <3CF12A19...@spamcop.net>,

Kenneth Brody <kenb...@spamcop.net> wrote:

> Short of that, get a version that runs on a multitasking system, such
> as Unix or Linux.

Unix OR Linux? Isn't Linux a dialect of Unix ?????

--
----------------------------------------------------------------
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40, S-114 38 Stockholm, SWEDEN
e-mail: pausch at saaf dot se
WWW: http://hem.passagen.se/pausch/index.html
http://home.tiscali.se/~pausch/

Bill Marcum

unread,
May 26, 2002, 5:09:12 PM5/26/02
to

In other words, what you want is a real operating system with real pipes
and multitasking.
Try Linux.

Bill Marcum

unread,
May 26, 2002, 5:17:34 PM5/26/02
to
On Sun, 26 May 2002 20:19:43 +0000 (UTC),
Paul Schlyter <pau...@saaf.se> wrote:
>In article <3CF12A19...@spamcop.net>,
>Kenneth Brody <kenb...@spamcop.net> wrote:
>
>> Short of that, get a version that runs on a multitasking system, such
>> as Unix or Linux.
>
>Unix OR Linux? Isn't Linux a dialect of Unix ?????
>
Not exactly. Unix is a trademark, which originally belonged to AT&T, and
last I heard it was owned by something called the X/Open Consortium.

Paul Schlyter

unread,
May 27, 2002, 1:54:59 AM5/27/02
to
In article <slrnaf2k69....@gigs.localnet>,
Interesting .... so e.g. Solaris, HP-UX, AIX and friends are no longer
Unix either? And Unix is no longer a family of OS'es but merely a
trademark?

Marco van de Voort

unread,
May 27, 2002, 2:43:03 AM5/27/02
to
In article <acshnj$ep8$1...@merope.saaf.se>, Paul Schlyter wrote:
> In article <slrnaf2k69....@gigs.localnet>,
> Bill Marcum <bma...@iglou.com> wrote:
>
>>>Unix OR Linux? Isn't Linux a dialect of Unix ?????
>>
>> Not exactly. Unix is a trademark, which originally belonged to AT&T, and
>> last I heard it was owned by something called the X/Open Consortium.

The definition of Linux is easy:

- Linux is a reimplementation from scratch of an operation system trying to
resemble both Unix branches.



> Interesting .... so e.g. Solaris, HP-UX, AIX and friends are no longer
> Unix either? And Unix is no longer a family of OS'es but merely a
> trademark?

There are multiple definition for "Unix".

The trademark. Afaik Corel/Novel currently owns that. How it is now, I don't
know, but years ago, you had to pay a lot of money, and pass some validation
suite to call yourself "Unix"

Another definition is merely being a direct descendant of the original Unix
code. This e.g. makes the BSDs a real Unix. It doesn't for Unix since it is
a separate independant implementation (but actually took and mimiced quite
some BSD code)


Kenneth Brody

unread,
May 27, 2002, 11:47:25 AM5/27/02
to
Paul Schlyter wrote:
>
> In article <3CF12A19...@spamcop.net>,
> Kenneth Brody <kenb...@spamcop.net> wrote:
>
> > Short of that, get a version that runs on a multitasking system, such
> > as Unix or Linux.
>
> Unix OR Linux? Isn't Linux a dialect of Unix ?????

No. It's a Unix-like operating system, but it is not Unix.

Kenneth Brody

unread,
May 27, 2002, 11:49:42 AM5/27/02
to
Paul Schlyter wrote:
[...]

> >>> Short of that, get a version that runs on a multitasking system, such
> >>> as Unix or Linux.
> >>
> >>Unix OR Linux? Isn't Linux a dialect of Unix ?????
> >
> > Not exactly. Unix is a trademark, which originally belonged to AT&T, and
> > last I heard it was owned by something called the X/Open Consortium.
>
> Interesting .... so e.g. Solaris, HP-UX, AIX and friends are no longer
> Unix either? And Unix is no longer a family of OS'es but merely a
> trademark?

The above-mentioned system were never Unix to begin with. They are all
Unix-like systems. Unix has always been a trademark, and you could only
call your system "Unix" with the blessings of the trademark holder, which
would only be done if your system really was Unix and not a lookalike.

Paul Schlyter

unread,
May 27, 2002, 12:52:33 PM5/27/02
to
In article <3CF25596...@spamcop.net>,

Kenneth Brody <kenb...@spamcop.net> wrote:

> Paul Schlyter wrote:
> [...]
>>>>> Short of that, get a version that runs on a multitasking system, such
>>>>> as Unix or Linux.
>>>>
>>>>Unix OR Linux? Isn't Linux a dialect of Unix ?????
>>>
>>> Not exactly. Unix is a trademark, which originally belonged to AT&T, and
>>> last I heard it was owned by something called the X/Open Consortium.
>>
>> Interesting .... so e.g. Solaris, HP-UX, AIX and friends are no longer
>> Unix either? And Unix is no longer a family of OS'es but merely a
>> trademark?
>
> The above-mentioned system were never Unix to begin with. They are all
> Unix-like systems. Unix has always been a trademark, and you could only
> call your system "Unix" with the blessings of the trademark holder, which
> would only be done if your system really was Unix and not a lookalike.

So if you claim something runs on "Unix or Linux", what does that mean?
Does it mean it probably won't run under e.g. Solaris or HP-UX or AIX,
sinc neither of these are "Unix or Linux" ?

Herman Dullink

unread,
May 27, 2002, 1:53:25 PM5/27/02
to
>Oh well, I guess it can't be done in DOS... Time to move to UNIX...

I wouldn't say it can't be done in DOS. It just can't be done how
you would like it to be done using pipe.

One solution that comes to mind is to make parser to install
someting to handle output to STDOUT and execute streamer.
Then every time streamer writes something to STDOUT,
parser will get it instantly.

H

0 new messages