In WSH (Windows Scripting Host), I want to compare multi-line data output by two jq commands using fc.exe
(FileCompare).
Performance is essential. It needs to be fast because this script is run very frequently on a slow system. By performance, I mean elapsed wall-time for the complete run.
I would love to be able to do this without creating temp files, but I am not currently aware of a way to do that in WSH.
So I thought I would simply use Wscript.Shell.Run
to run jc.exe
and then redirect the output to a file. Ah, but some claim that Wscript.Shell.Run
does not allow redirecting output.
So I moved on to Wscript.Shell.Exec
, which everyone agrees should allow output redirection. But every example I've seen has .Exec
running a separate instance of the command processor in order to allow stdout redirection.
(e.g. WshShell.Exec("cmd /c jc.exe ... > output.txt")
instead of WshShell.Exec("jc.exe ... > output.txt")
.
I'm guessing this is required for some reason, but it significantly impacts performance.
Could this be an XY problem? Sure, almost everything can be done differently and thus can be called an XY problem. But I'm using tools I have at my disposal and that I'm familiar with.
Is it possible to accomplish what I want in WSH efficiently?
https://stackoverflow.com/questions/65534737/how-to-performance-optimize-standard-output-stdout-redirection-from-an-applica January 02, 2021 at 07:43AM
没有评论:
发表评论