× 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.



Hello All,

Hopefully one of you will have some ideas.

I have a program (*PGM) that expects its input from stdin rather than via
argv[].  I do not have the source to the program.  I want to
programmatically put the program's input on stdin and then call that program
to do its stuff.  How do I get data on to stdin in the proper form so
another program can get that data by reading stdin?

I want to accomplish something similar to the pipe function that a Unix
shell provides.  Indeed, the AS/400 QSHELL does this also when I run
something like:

        ls | grep temp

causing the output from ls (via stdout) to be rerouted to grep (via stdin).

This is also similar to how the HTTP server sends data to a CGI program.

I created two little test programs.  The first attempts to put data on stdin
and then calls the second one.  The second one simply reads stdin and prints
whatever it finds.  However, although they run with no errors they don't
actually work.  This doesn't seem impossible so I must be missing something
obvious.

I am pretty sure I could do this if I spawned a BCI job to invoke the
"stdin" program but I don't want to do that.  I want to call the "stdin"
program in an interactive job using a dynamic program call.

I have tried writing to stdin which seems to work in that no error is
generated but the second program does not seem to receive that data.

I have tried flushing stdin after writing the data but that didn't work.

I have tried closing stdin after writing the data but that didn't work (not
that I expected it to).

I have tried overriding stdin to QINLINE and writing the data but that
didn't work.

I have tried to reopen stdin as writable but that actually failed with
errnoÓ014 which doesn't help much.

I am going to try overriding stdin to a file in QTEMP and putting the data
in that file.  I expect this to work but I really want to do it without the
temporary file.  I really want to have program A write to stdin, call
program B, which reads from stdin.

Regards,
Simon Coulter.

«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
«» FlyByNight Software         AS/400 Technical Specialists       «»
«» Eclipse the competition - run your business on an IBM AS/400.  «»
«»                                                                «»
«» Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   «»
«» Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /   «»
«»                                                           X    «»
«»               ASCII Ribbon campaign against HTML E-Mail  / \   «»
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.