× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Tue, 16 Apr 2002, Peter Connell wrote:

> James, Scott, Jim.
> Thanks. I'm aware that OS like Unix and the C (or C++) language provide an
> operator that permits the output of one program to be easily piped to
> another but the challenge is to prove that this can be achieved effectively
> on OS/400 since the analagous facility to override stdout appears to be
> ignored when the QtmhWrStout Api is used to generate stdout.

Is it ignored?  I don't know if it is, but here is a test:

1. write an RPG program that writes "Hello World" to stdout.
2. From QSH invoke your program and pipe the output to grep like this:
        hellopgm | grep ello
3. Again from QSH invoke your program and redirect the output to a file:
        hellopgm > /tmp/hellooutput

All this should work.  Why?  because QSH will tell the OS how the various
stdins and stdouts should be set up.  So your goal of having one program
write to stdout and another program read it can be done if they are
invoked in this way using QSH.  But the first program cannot be called and
then another program read the first's stdout later, because the stdout is
not stored anywhere.  Use QSH and make life easy.

If you really do want to delay invoking the second program until after the
first has started then just use a temporary file.  If you were using
stdout before then use a file on the IFS since it won't require you to
make any significant code changes.  It probably won't perform nearly as
well but it will get the job done.

> Populating stdout from within an RPGLE cgi program (or C) is a relatively
> simple matter using the built-in Apis or functions that the language
> provides since this is how all CGI programs are written. I suspect that

Again, I think it is misleading to describe writing to stdout as
populating it.  stdout is never populated.  If something (like the screen)
is connected to stdout then that something will receive whatever is
written to stdout.  But if nothing is connected then anything written to
stdout just disappears.  IOW, the contents of stdout are always nothing.

However, stdout (AFAIK) is always connected to something, that something
usually being the screen.

> The piping technique would therefore appear be a mechanism the merely primes
> the OS before making a program call so that it bypasses the usual low level
> process that generates stdout and instead passes the output stream to a
> redirected actual file that is available for read.

Not quite.  stdout always exists.  A pipe is an kernel level device that
connects one stdout to another stdin.  A pipe does not create an actual
file.

James Rich
james@eaerich.com



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.