KB Article #52686

PROCESS.STARTCOMMAND

Problem

Why the source ( in attachments) does not work?



DECLARE $startCommand[] STRING;
DECLARE $status         STRING;
DECLARE $PId[]          INTEGER;
PRINT "START\n";
$startCommand[1] = "echo 'hello world' > echo.tst";
$PId[1] = PROCESS.STARTCOMMAND($startCommand[1]);
PRINT "Process with pid " & $Pid[1] & " started." & "\n";
PROCESS.WAIT $PId PID $PId[1] EXITSTATUS $Status WAIT 30;
PRINT "END\n";


Resolution

Because it runs processes without using the shell and ' >' is a shell operator. It's part of the syntax of the shell language.
It simply finds the executable file (/bin/echo) and passes it the parameters, without going through the shell. So to run the script go through the shell to have your shell syntax parsed and interpreted.