Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to execute linux command from c#

using System;
using System.Diagnostics;

namespace runGnomeTerminal
{
    class MainClass
    {
        public static void ExecuteCommand(string command)
        {
            Process proc = new System.Diagnostics.Process ();
            proc.StartInfo.FileName = "/bin/bash";
            proc.StartInfo.Arguments = "-c " " + command + " "";
            proc.StartInfo.UseShellExecute = false; 
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start ();

            while (!proc.StandardOutput.EndOfStream) {
                Console.WriteLine (proc.StandardOutput.ReadLine ());
            }
        }

        public static void Main (string[] args)
        {
            ExecuteCommand("gnome-terminal -x bash -ic 'cd $HOME; ls; bash'");
        }


    }
}
Comment

Run C# script on linux terminal

sudo apt update
sudo apt install mono-complete
mcs -out:filename.exe filename.cs
mono filename.exe
Comment

PREVIOUS NEXT
Code Example
Csharp :: start command line from c# 
Csharp :: c# entity framework code first connection string 
Csharp :: unity how to get the first word from string 
Csharp :: unity change particle system sorting layer via script 
Csharp :: select a object from list based on a value csharp 
Csharp :: c# list sort by property string 
Csharp :: mathf.clamp unity 
Csharp :: unity button press onclick click add C# 
Csharp :: c# list index 
Csharp :: get execution directory c# 
Csharp :: c# array of strings 
Csharp :: compile in one single exe c# 
Csharp :: c# how to refresh your binding source 
Csharp :: replace elements with greatest element on right side 
Csharp :: how to chagne rotation in unity 
Csharp :: c# compile code at runtime 
Csharp :: c# get month number 
Csharp :: c# get enum value from string 
Csharp :: error provider c# 
Csharp :: unity topdown 
Csharp :: c# search string array 
Csharp :: bytes to httppostedfilebase c# 
Csharp :: rotating an object in unity 
Csharp :: c# environment variables 
Csharp :: newtonsoft create dynamic object 
Csharp :: unity random number 
Csharp :: convert string to int c# 
Csharp :: unity how to move an object 
Csharp :: nested dictionary c# 
Csharp :: editorfor date format mvc 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =