JamesBowen
19+ years progress programming and still learning.
I may be teaching you to suck eggs. But think this could be of some use.
The following code enables the developer to handle standard in and standard out on a *nix platform.
procPipeExample.p
To run type:
Hope this useful anyone.
The following code enables the developer to handle standard in and standard out on a *nix platform.
procPipeExample.p
Code:
DEFINE STREAM sStdin.
DEFINE STREAM sStdout.
DEFINE VARIABLE cImportLine AS CHARACTER NO-UNDO INITIAL ''.
IF OPSYS NE "UNIX" THEN
DO:
MESSAGE SUBSTITUTE('&1 can only run on a Linux or Unix bassed OS.',
PROGRAM-NAME(1))
VIEW-AS ALERT-BOX ERROR.
QUIT.
END.
IF NOT SESSION:BATCH-MODE THEN
DO:
MESSAGE SUBSTITUTE('&1 can only run in BACH Mode. Use a -b parameter.',
PROGRAM-NAME(1))
VIEW-AS ALERT-BOX ERROR.
QUIT.
END.
OUTPUT STREAM sStdout TO '/dev/stdout' NO-CONVERT NO-ECHO.
INPUT STREAM sStdin FROM '/dev/stdin' NO-CONVERT NO-ECHO.
REPEAT:
cImportLine = ''.
IMPORT STREAM sStdin UNFORMATTED cImportLine.
PUT STREAM sStdout UNFORMATTED SUBSTITUTE('&1: &2',
NOW,
cImportLine) SKIP.
END.
INPUT STREAM sStdin CLOSE.
OUTPUT STREAM sStdout CLOSE.
QUIT.
Code:
cat procPipeExample.p | _progres -b -p procPipeExample.p