os-command output

atuldalvi

Member
I am executing one unix command through os-command statement. Now i want to store the output of that unix command into progress variables.

Is it possible ? If so then how ?
 
/* a.p */

DEFINE STREAM ls.
DEFINE VARIABLE lc_command AS CHARACTER NO-UNDO.
DEFINE VARIABLE lc_result AS CHARACTER NO-UNDO.
DEFINE VARIABLE lc_ret AS CHARACTER NO-UNDO.

lc_command = "netstat -a".
INPUT-OUTPUT STREAM ls THROUGH VALUE (lc_command) NO-ECHO UNBUFFERED.

REPEAT:
IMPORT STREAM ls UNFORMATTED lc_result.
lc_ret = lc_ret + lc_result + "~n".
END.
INPUT-OUTPUT STREAM ls CLOSE.

MESSAGE lc_ret VIEW-AS ALERT-BOX.
 
Back
Top