October 27, 2016 at 12:05 pm #4204
Sometimes you may need to call Unix commands/call unix scripts from SQR, in that case CALL SYSTEM command comes in handy.
Below is the syntax of CALL SYSTEM command-
CALL SYSTEM USING command status [WAIT|NOWAIT]
SYSTEM– Specifies that this CALL command issues an operating system command.
command – Specifies the operating system command to execute. The command can be a quoted string, string variable, or column.
status;- Contains the status returned by the operating system. The status must be a numeric variable. The value returned in status is system-dependent as follows:UNIX/Linux: Zero (0) indicates success. Any other value is the system error code.PC/ Microsoft Windows: A value less than 32 indicates an error.
WAIT|NOWAIT – (Microsoft Windows only): WAIT specifies that SQR suspend its execution until the CALL SYSTEM command has finished processing. NOWAIT specifies that SQR start the CALL SYSTEM command but continue its own processing while that command is in progress.
For Microsoft Windows, the default is NOWAIT. On UNIX\Linux operating systems the behavior is always WAIT.
Below is sample code to run COPY command from SQR using CALL SYSTEM.
let $cmd = 'cp /home/directory1/test.csv /home/directory2/test.csv' display $cmd CALL SYSTEM USING $cmd #call_status WAIT evaluate #call_status when = 0 display 'Valid connection' break when = 1 display 'ERROR: Connection cannot be made to SF' break when = 2 display 'Valid Log File' break when = 3 display 'ERROR: Log file does not exist for file transfer' break when = 4 display 'File' break when = 5 display 'file does not exist for file transfer' break end-evaluate
You must be logged in to reply to this topic.