Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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
Shell :: how to run shell script 
Shell :: react native ubuntu 20.04 
Shell :: how to push changes to branch in git 
Shell :: merge child branch to parent git 
Shell :: close tcp port on mac 
Shell :: how to install fish in debian 
Shell :: install glfw3 
Shell :: git global settings ssh 
Shell :: replace delimiter for enter command 
Shell :: install rclone FOR UBUNTU 
Shell :: create user linux 
Shell :: install gitlab runner on centos 
Shell :: bash regex if condition 
Shell :: bash find text in specific file 
Shell :: apple logo in terminal 
Shell :: how to setup ubuntu for windows in visual studio code 
Shell :: git mirror repository 
Shell :: find files size greater than 100mb in linux 
Shell :: Ubuntu – Root folder access via gui 
Shell :: Postman Collection Format v1 is no longer supported and can not be imported directly. You may convert your collection to Format v2 and try importing again. 
Shell :: sed remove first line 
Shell :: export variable bash 
Shell :: add python to path zsh 
Shell :: git got to previous commit 
Shell :: change remote origin git 
Shell :: hello world 
Shell :: git diff of a file between two commits 
Shell :: nvm cheatsheet 
Shell :: aws cli has no installation package in ubuntu server 20.04 how to solve 
Shell :: wsl2 vs virtualbox performance 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =