Raido Kaju
New Member
I am attempting to use an external process via stdin and stdout to grab a file from a base64 encoded zip file.
The way I am currently going about it is with this code:
The problem is that the program hangs. If I close the stream with INPUT-OUTPUT STREAM io CLOSE. Then I get a result just fine (checked by logging in the executable) but I cannot read the response.
The same executable works just fine if I use it directly from the command-line and pipe stdin and stdout.
To me the problem seems to be that although I am trying to close the output stream after writing it still keeps it open.
Any advice would be much appreciated.
The way I am currently going about it is with this code:
Code:
DEFINE STREAM fin.
DEFINE STREAM io.
DEFINE VARIABLE mData AS MEMPTR NO-UNDO.
DEFINE VARIABLE lData AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cLine AS CHARACTER NO-UNDO.
DEFINE VARIABLE cXml AS CHAR INIT '' NO-UNDO.
FILE-INFORMATION:FILE-NAME = 'D:\input.zip'.
SET-SIZE(mData) = FILE-INFORMATION:FILE-SIZE.
INPUT STREAM fin FROM 'D:\input.zip' BINARY NO-MAP NO-CONVERT.
IMPORT STREAM fin mData.
INPUT STREAM fin CLOSE.
INPUT-OUTPUT STREAM io THROUGH VALUE ('gounzip.exe -name K11.txt -b64=true') BUFFER.
lData = BASE64-ENCODE(mData).
PUT STREAM io UNFORMATTED STRING(lData).
OUTPUT STREAM io CLOSE.
SET STREAM io cLine.
INPUT-OUTPUT STREAM io CLOSE.
SET-SIZE(mData) = 0.
The problem is that the program hangs. If I close the stream with INPUT-OUTPUT STREAM io CLOSE. Then I get a result just fine (checked by logging in the executable) but I cannot read the response.
The same executable works just fine if I use it directly from the command-line and pipe stdin and stdout.
To me the problem seems to be that although I am trying to close the output stream after writing it still keeps it open.
Any advice would be much appreciated.
Last edited by a moderator: