[Mono-list] Execute a shell program form a C# program

Madars Vitolins madars.vitolins at gmail.com
Thu Apr 26 01:58:21 EDT 2007


Hi,

I have used such method to exec shell command:

protected String ShellExec(
                String cmd,
                String path,
                String parms,
                out int exit_code)
        {
            System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo(
                     path + cmd, parms);
            psi.RedirectStandardOutput = true;
            psi.UseShellExecute = false;

            System.Diagnostics.Process p = System.Diagnostics.Process.Start
(psi);
            string tool_output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            exit_code = p.ExitCode;
            return tool_output;
        }


Regards,
Madars.

On 4/23/07, Gazzall <gaby_sev at hotmail.com> wrote:
>
>
> Hi,
>
> In my C# program I am writing a .sh code.
> In this .sh code I have the following command:
> java -jar JavaApplication1.jar "/home/user/Debug/Etat/2.jrxml"
> "/tmp/Tmp/f021aeb7-0.xml" "/tmp/Tmp/59f34fed-2ada-.xml"
>
> In my c# program a launching the .sh like that:
> myProcess = System.Diagnostics.Process.Start("file.sh");
> myProcess.WaitForExit();
> myProcess.Close();
>
> The problem is that my program does not start the process.
>
> Do you know Why?
>
> Or do you have an idea to execute shell command like
> java -jar program ......
>
>
> Thanks
>
> Gazzall
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Execute-a-shell-program-form-a-C--program-tf3630397.html#a10137289
> Sent from the Mono - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070426/014a46e4/attachment.html 


More information about the Mono-list mailing list