I have spent many hours on this problem and am hoping to get insight.
I cannot seem to find out how to get the number of rows from a dos command into a variable in Data Services SP5.
The below returns the number of rows in a file, from a windows command prompt:
type "\\path\to\file\nullRecords.csv" | find /c /v ""
In my case, this returns 10 when I run it in a command prompt as the user my DS job runs as. However, now that I am using SP5 I cannot seem to return anything using exec. The following:
$foo =exec('cmd','type "\\\path\to\file\nullRecords.csv" | find /c /v ""',8); print ($foo);
The above prints out "0:". $foo is a global varchar length 9999. The 0 seems to suggest that the command is executing correctly. However no standard out is printing. Running the command manually does print this out (I have to change the \\\ to \\ as the only required change).
The manual for scripting suggests that the 8 return code should print both standard out and any error.
When I change this to be a 0, 1, 2, 3, 4, or 5 (instead of 8) I get a NULL return every time. This is quite confusing because this does not seem possible for the list of return codes for each to be NULL always (??).
Previously, or with other commands (like just 'dir') the 8 flag to the cmd exec() would print everything from standard out. I am not sure why this doesn't work here.
I also tried placing this in a .bat file and executing it from the command line, but that also does not seem to work to return anything.
What am I missing here? I've read through the documentation on exec thoroughly but clearly missed something.