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 :: c# entity framework code first connection string 
Csharp :: how do i make multiplayer in unity 
Csharp :: rb.addforce c# 
Csharp :: unity deactivate all colliders of a gameobject 
Csharp :: c# convert string to int 
Csharp :: frame time unity 
Csharp :: c# date 
Csharp :: c# update value in a json file 
Csharp :: how to close and reopen an app in c# 
Csharp :: call function from another script unity 
Csharp :: datagridview column color c# 
Csharp :: how to sort string array alphabetically in c# 
Csharp :: c# parse the date in DD/MMM/YYYY format 
Csharp :: c# socket listen on port 
Csharp :: VLC .net 
Csharp :: unity spherecast 
Csharp :: c# get all the column names from datagridview 
Csharp :: unity set dropdown value 
Csharp :: c# remove special characters from string 
Csharp :: c# how to write an array in a single line 
Csharp :: clear controls from panel c# 
Csharp :: Cursor Lock and Visible in Unity 
Csharp :: list all files in directory and subdirectories c# 
Csharp :: c# list remove item based on property duplicate 
Csharp :: c# combobox selected item 
Csharp :: c# string tob64 
Csharp :: What is the difference between String and string in C#? 
Csharp :: get folder path winforms 
Csharp :: c# sum of list 
Csharp :: how to open website from c# program 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =