I try to use:
string result;
string path = "C:/winccoa.projects/filters/bin/tools/rxrepl.exe";
string cmd = "'opcki' | " + path + " -s 'op' -r 'tata'";
system(cmd, result);
DebugN(result);
But in LogViewer i see nothing, instead ["tatacki"]
Why? What i doing wrong?
In PowerShell that works fine:
PS C:\> 'opcki' | C:/winccoa.projects/filters/bin/tools/rxrepl.exe -s "op" -r "tata"
tatacki
I'm assuming that WinCC's
system()function targetscmd.exe, notpowershell.exe(which is typical, because historicallycmd.exehas been the default shell, and APIs are unlikely to change, so as to maintain backward compatibility).Therefore, formulate your command for
cmd.exe:Not the use of
echoto produce output and the omission of single-quoting ('...'), whichcmd.exedoesn't recognize.If embedded quoting were needed, you'd have to use
`"inside"..."PowerShell strings (or use'...'PowerShell strings (whose content is taken literally) and embed"chars. as-is).