Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Script plugin : IO.Execute(cmd)
MortenMacFly:
--- Quote from: LETARTARE on February 24, 2012, 02:00:20 pm ---But after the removal of marks separating, I can not separate the flow 'stderr' and 'stdout',
especially in the case or 'stderr' provides me with warnings.
But it's better than nothing.
--- End quote ---
OK - then provide another boolean parameter like "errors_only" which is false by default but if you enable it it will skip the stdout. This would then be your first solution, but with the advantage, then it can be used for even more than that (special) case. ;-)
LETARTARE:
After several tries, I think the best solution would be:
--- Code: ---wxString ExecuteAndGetOutputAndError(const wxString& command, bool with_error = false}
{
if (!SecurityAllows(_T("Execute"), command))
return wxEmptyString;
wxArrayString output;
wxArrayString error;
wxString str_out;
wxExecute(command, output, error, wxEXEC_NODISABLE);
if (with_error && !error.IsEmpty() )
str_out += GetStringFromArray(error, _T("\n"));
if (!output.IsEmpty())
str_out += GetStringFromArray(output, _T("\n"));
return str_out;
}
--- End code ---
well it looks like 'ExecuteAndGetOutput (const wxString & command)' plus 'stderr' option.
In 'command' you can always redirect 'stdout to a file and get only' stderr 'on the function.
[attachment deleted by admin]
MortenMacFly:
--- Quote from: LETARTARE on February 25, 2012, 07:39:26 am ---In 'command' you can always redirect 'stdout to a file and get only' stderr 'on the function.
--- End quote ---
You mean doing something like "mytool.exe 2>nul" is possible with wxExecute? Did you try? If so, then in fact this would be the best solution. :D
LETARTARE:
yes, I tested with 'wxUSE_STREAMS = 1' for 'wxmsw28u_gcc_custom.dll'.
For an external command 'mytool.exe 1> foo.txt',
for an internal command 'cmd / C dir 1> foo.txt'
and I get errors with 'ExecuteAndGetOutputAndError (command, true)'
or the opposite '... 2> err.txt ' and ' ExecuteAndGetOutputAndError (command) '
Can be simplified by 'ExecuteAndGetOutput (wxString, bool = false)'
without affecting existing programs :
--- Code: ---wxString ExecuteAndGetOutput(const wxString& command, bool with_error = false
{
if (!SecurityAllows(_T("Execute"), command))
return wxEmptyString;
wxArrayString output;
wxArrayString error;
wxString str_out;
wxExecute(command, output, error, wxEXEC_NODISABLE);
if (with_error && !error.IsEmpty() )
str_out += GetStringFromArray(error, _T("\n"));
if (!output.IsEmpty())
str_out += GetStringFromArray(output, _T("\n"));
return str_out;
}
--- End code ---
LETARTARE:
@MortenMacFly
I use this patch since February 27 and I've had no problem on my setup.
Is it possible to integrate it into 'C :: B'?
Good day.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version