[Mono-winforms-list] How to run commands from mono c#

asabhijitshelar at gmail.com asabhijitshelar at gmail.com
Tue Dec 3 09:14:53 UTC 2013


How to run commands from terminal in mono C#.

I need to execute commands from C# in mono on mac OS-X. I need to run
command and then capture output. I need to open calabash-android console and
then continuously run commands from that terminal.

what is c# code needs to be written in order to achieve it.

For example

LaunchCommandAsProcess
  p = new Process();
            p.StartInfo.FileName = @"#!/bin/sh\n";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;            
            p.Start();

            stdIn = p.StandardInput;
            p.OutputDataReceived += Process_OutputDataReceived;
            p.ErrorDataReceived += Process_OutputDataReceived;
            p.BeginOutputReadLine();
            p.BeginErrorReadLine(); 
I need to achieve something this

private void StartDevice()
        {
            string appName = toolStripTxtUrl.Text;

            if (appName == "")
            {
                MessageBox.Show("Please select apk");
                return;
            }
            string[] tempData = appName.Split('\\');
            string apk = tempData[tempData.Length - 1];
            string apkpath = appName.Replace("\\" + apk, "");

            cmd = new LaunchCommandAsProcess();
            cmd.OutputReceived += new
LaunchCommandAsProcess.OutputEventHandler(launch_OutputReceived);
            //  cmd.OutputFinished += new
LaunchCommandAsProcess.OutputFinishedEventHandler(cmd_OutputFinished);

           // cmd.SendCommand(@"cd D:\ANDROID\Calabash");
            cmd.SendCommand(@"cd " + apkpath);

           // cmd.SendCommand(@"D:");
            cmd.SendCommand(tempData[0]);

            cmd.SendCommand("calabash-android.bat console " + apk);
           // cmd.SendCommand(@"C:\Ruby193\bin\calabash-android.bat console
cc.apk");

            cmd.SendCommand("start_test_server_in_background");

            cmd.SendCommand(@"C:\Ruby193\bin\calabash-android.bat console "
+ apk);

            //cmd.SendCommand(@"C:\Ruby193\bin\calabash-android.bat console
cc.apk");

            oclsCommon.Wait(20);
        }



--
View this message in context: http://mono.1490590.n4.nabble.com/How-to-run-commands-from-mono-c-tp4661426.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.


More information about the Mono-winforms-list mailing list