Hack Forums
[C#] Linux Terminal Commands - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Linux Terminal Commands (/showthread.php?tid=5991994)



Linux Terminal Commands - HardStoN - Jul 22, 2019

Hi there
ive recently moved to linux and i need to start a bash window in separate window from my current program so what i did was
download mono and mcs and made my secondary program (the one i need to open) to exe this is the code behind:
Code
int port = Convert.ToInt32(args[0]);
            string path = args[1];

            Process.Start("/bin/bash", "-c \"cd " + path + " && ./ngrok tcp " + port + "\"");

And ive opened it using Process.Start and added some arguments to it but the exe was opened in the same window as mine
is there any way i can solve that?

Thanks for help


RE: Linux Terminal Commands - GraeskMytologi - Jul 23, 2019

(Jul 22, 2019 02:36 AM)HardStoN Wrote:  Hi there
ive recently moved to linux and i need to start a bash window in separate window from my current program so what i did was
download mono and mcs and made my  secondary program (the one i need to open) to exe this is the code behind:
Code
int port = Convert.ToInt32(args[0]);
           string path = args[1];

           Process.Start("/bin/bash", "-c \"cd " + path + " && ./ngrok tcp " + port + "\"");

And ive opened it using Process.Start and added some arguments to it but the exe was opened in the same window as mine
is there any way i can solve that?

Thanks for help

Not quite sure since I haven't tested on linux, but using the Process.Start() overload that takes a ProcessStartInfo object as parameter, you can set UseShellExecute = true

Code
ProcessStartInfo startInfo = new ProcessStartInfo
{
   FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32", "cmd.exe"),
   Arguments = "/C echo 123",
   UseShellExecute = true
};

Process.Start(startInfo);



RE: Linux Terminal Commands - DNA - Jul 23, 2019

This should help you

https://askubuntu.com/questions/506985/c-opening-the-terminal-process-and-pass-commands