Util.Cmd execution of LPRun is passing result file as argument.

I have a master query running several other queries using LPRun through Util.Cmd
Due to memory problems I must run out of proc (Util.Cmd instead of running queries directly) both to reduce the overall memory footprint and to not affect the master query in the event of an outofmemory exception. Due to legacy libraries, I must stick to 32 bit.

Util.Cmd is passed two strings, and I suspect it is using logic to determine the need for wrapping up arguments in escape syntax. The behaviour does not appear to be consistent.

This should reproduce the problem.

var sampleargs = @"""C:\LINQPad Queries\LPRunArgs.linq"" ""ARG 2"" ""ARG 3"" ""ARG 1"" ""ARG 1"" > ""c:\temp\result file.html""";
var runcmd = @lprun;
Util.Cmd (runcmd,sampleargs);

This results in ">" and "c:\temp\result file.html" being passed in as arguments to the LPRunArgs query and no output file is being produced. Am I putting the piping information in the wrong location?


  • Rather than shelling out to Util.Cmd from within LINQPad, have you considered calling Util.Run?
  • Hi Joe. Thanks for responding.
    Yes, I have considered it. That was what I meant by "running them directly" in the first paragraph. I worry that an outofmemory exception in the called query will affect the calling query.
  • Try this:

    File.WriteAllLines (@"c:\temp\result file.html", Util.Cmd (runcmd,sampleargs, true));
  • That works like a charm. Thank you.
    Strictly speaking, a very large output will now conceivably be able overthrow the calling query.
    But it is working and I now feel that I have more control over that part.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!