[Mono-list] How to Start Concatenated Processes by Using System.Diagnostics.Process?

Robert Jordan robertj at gmx.net
Thu Jun 17 10:25:04 EDT 2010


On 17.06.2010 14:59, Jacek Rużyczka wrote:
> Hi folks,
>
> I would like to start concatenated processes from my C# / Mono app. OK, here
> we've got the System.Diagnostics.Process and
> System.Diagnostics.ProcessStartInfo classes...but on the shell I would have to
> issue a statement like this one:
>
> pdflatex receipt_60.tex&&  gpg --batch --local-user scott --passphrase tiger
> --sign receipt_60.pdf
>
> First, pdflatex generates a PDF document out of an already-existing LaTeX
> source code file, and then GnuPG signs it. So I have two commands (of which
> gpg is to be called only when #1 has been completed successfully), and both
> have arguments.
>
> The question is now: How shall I implement all this with
> System.Diagnostics.Process? Please note that ProcessStartInfo.Verbs may be the
> wrong choice as pdflatex and gpg work against different files.
>
> Or do I have to call Process.Start() for the pdflatex command, wait for it to
> complete, and issue another Process.Start() for gpg?

This. Or pass the commands to a shell process (untested):

ProcessStartInfo info = new ProcessStartInfo();
info.UseShellExecute = false;
info.FileName = "/bin/bash";
info.Arguments = "-c 'pdflatex -interaction=nonstopmode receipt_60.tex 
&& gpg ... '";

Note the quoting of the string for the -c option and latex
-interaction switch.

Robert



More information about the Mono-list mailing list