[Mono-list] ProcessStartInfo and arguments with a backslash
Uli Hertlein
uli at xdt.com.au
Tue Oct 4 07:40:36 EDT 2011
Hi Yves,
On 10/01/2011 08:17 PM, Yves Goergen wrote:
> I am debugging a problem with my .NET application calling a UNIX
> programme with arguments. The bash command line looks like this:
>
> /usr/bin/smem -P '/usr/sbin/exim4(\s|$)'
>
> My C# code to do exactly that is the following:
>
> string processPath = "/usr/sbin/exim4(\s|$)";
> ProcessStartInfo psi = new ProcessStartInfo(
> "smem",
> "-P '" + processPath + "'");
> psi.RedirectStandardOutput = true;
> psi.UseShellExecute = false;
> Process p = Process.Start(psi);
>
> But this is what the started programme gets as arguments:
>
> ['/usr/bin/smem', '-P', '/usr/sbin/exim4(s|$)']
I guess that Mono is using bash to execute the command line and that is doing an additional 'resolve'.
Try to set:
psi.UseShellExecute = false; // Default is true
or double-escape the argument as in:
string processPath = "/usr/sbin/exim4(\\\\s|$)";
Cheers,
/uli
--
Ulrich Hertlein
Research and Development mailto:uli at xdt.com.au
XDT Pty Ltd http://www.xdt.com.au
More information about the Mono-list
mailing list