[{ALLOW view All}]
[{ALLOW edit Authenticated}]
{{{
*&---------------------------------------------------------------------*
*& Report ZP00ZI_UNIXCMD *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZP00ZI_UNIXCMD.
SELECTION-SCREEN BEGIN OF BLOCK P1.
PARAMETERS: LOGFILE TYPE C LENGTH 200 LOWER CASE DEFAULT '/temp/exelog',
CMD TYPE C LENGTH 200 LOWER CASE DEFAULT 'ls -l'.
SELECTION-SCREEN END OF BLOCK P1.
START-OF-SELECTION.
DATA: LINE TYPE STRING.
OPEN DATASET LOGFILE FOR OUTPUT FILTER CMD IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE: / 'execution error'.
ELSE.
CLOSE DATASET LOGFILE.
CONCATENATE 'Command: ' CMD INTO LINE IN CHARACTER MODE.
WRITE: / LINE.
WRITE: / SY-ULINE.
OPEN DATASET LOGFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET LOGFILE INTO LINE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE: / LINE.
ENDDO.
CLOSE DATASET LOGFILE.
DELETE DATASET LOGFILE.
ENDIF.
}}}