M
M
Midzakikayo2020-10-13 19:06:19
linux
Midzakikayo, 2020-10-13 19:06:19

How to access the Linux Terminal in a C# console application?

All the best! I solve a problem. You need to access the application to the Linux terminal. wrote the code.

static void terminalInput(string command)
        {         
          ProcessStartInfo startInfo = new ProcessStartInfo();
          startInfo.FileName = "/bin/bash";
          startInfo.Arguments = "~/test";
          Process.Start(startInfo);
        }


the script is written like this
#!/bin/bash
touch test.txt
echo "hi world! > test.txt"

The script itself is executed separately. But there is no access to it through the program.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sergey, 2020-10-13
@Midzakikayo

the shell understands, but the c# code does not know what a tilde is

O
OCTAGRAM, 2020-10-15
@OCTAGRAM

If you add "-c" as the first argument, bash will perform HOME substitution in ~

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question