Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

programmatically write bash script 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

PREVIOUS NEXT
Code Example
Csharp :: how to execute linux command from c# 
Csharp :: cs entity framework 
Csharp :: wpf get screen size 
Csharp :: Check if two linked lists merge. If so, where? 
Csharp :: fluentassertions force exceptions 
Csharp :: c# open url 
Csharp :: unity clamp rotation 
Csharp :: c# list append 
Csharp :: C# .net core convert to int round up 
Csharp :: unity random 
Csharp :: unity look at target 
Csharp :: c# compile into an exe 
Csharp :: c# combine list of bool 
Csharp :: c# todictionary linq 
Csharp :: c# string.join 
Csharp :: https port 
Csharp :: c# write byte[] to stream 
Csharp :: loop through string array c# 
Csharp :: selenium open chrome c# 
Csharp :: 2d topdown movement unity 
Csharp :: c# append text to file 
Csharp :: Unity Rigidbody how to set zero momentum 
Csharp :: c# using file.io 
Csharp :: c# ftp file download 
Csharp :: linq query select top 1 c# 
Csharp :: c# find largest number in list 
Csharp :: c# static meaning 
Csharp :: c# dictionary to json 
Csharp :: how to see image from website in wpf 
Csharp :: how to move object with keyboard in unity 3D 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =