How to capture error message from RunCommand? lazarus / 61-Beginners ---------------------------------------------------------------------- bulrush · 2016-06-21 16:31 I have this code to run an external command: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cmd:='pandoc'; if RunCommand(cmd, ['-f', 'markdown_mmd','-t', 'xhtml', infn], outs) then  tsl.Text:=outselse  begin  writeln(procname+'ERROR: Error running "'+cmd+'" on '+infn+'. outs='+outs);  myexit(); //Completely exits program using Halt(0)  end; and in a normal run the XHTML is put into outs. But I'm getting an error which is not being put into outs. outs is blank. How do I run an external Windows cmd command and capture the error message? I'm wondering if RunCommand only captures STDOUT and not STDERR where errors normally go. NOTE: pandoc.exe is in the same dir as the application exe file. So I shouldn't have to use a full path with pandoc, right? The code above has been working for days, until just now. I just want to double check I can catch error messages using this method. I ran the command manually in a cmd window and saw the error. I will pursue that too. I even tried this code, which didn't send the error to outs. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if RunCommand(cmd, ['-f', 'markdown_mmd', '-t', 'xhtml', infn, '2>&1'], outs) then Thanks! ---------------------------------------------------------------------- molly · 2016-06-21 17:11 Quote from: bulrush on June 21, 2016, 06:31:10 pmwondering if RunCommand only captures STDOUT and not STDERR where errors normally go. A quick glance at the runcommand implementation seems to suggest as such. e.g. the internalruncommand function is called (and does provide a string for StdErr caption), except that it does not do anything with that string. I don't believe Runcommand allows you to combine stdout and stderr with using its parameters (which could have been a solution). Perhaps you might want to take a look at this wikipage because afaik using runcommand is deprecated. edit: BTW: Using stderr vs stdout for returning error messages isn't really black & white material. It depends on the command being executed. ---------------------------------------------------------------------- marcov · 2016-06-21 19:20 Quote from: molly on June 21, 2016, 07:11:55 pmPerhaps you might want to take a look at this wikipage because afaik using runcommand is deprecated. This is incorrect. All forms (Executeprocess, TProcess and Runcommand) that use a single string as commandline are deprecated. All versions of these functions that separate the arguments into an array of string or tstringlist are still supported. So if you get an deprecated message, that is the form, not the actual command that is deprecated. ---------------------------------------------------------------------- molly · 2016-06-21 19:54 Oops, my bad. i stand corrected. Thank you for having noticed marcov. Seems that my glance was a bit to quick