« Return to Thread: Executing Shell commands

Executing Shell commands

by Zaizeku :: Rate this Message:

Reply to Author | View in Thread

Hey Guys I'm fairly new using C# on linux and well I'm having some trouble trying to execute a shell command from the code, I tried doing it the way I did it in C and C++ but to no avail, found some tutorials and guides on how to execute shell commands on C# but what I can only do is execute a program, what I really want to do is be able to execute a command like for example:

rm -r <Directory>

and well I'm not having any luck, here is what I have right now

                System.Diagnostics.Process pipes = new System.Diagnostics.Process();
                pipes.EnableRaisingEvents = false;
               
                pipes.StartInfo.FileName = "gnome-terminal";
                //pipes.StartInfo.Arguments = "rm -r /home/zaizeku/Desktop/test.txt";
                pipes.Start();

this does execute the terminal but the argument which I think would be the command is never even written/executed at all, I first tried just plainly doing this
             
              System.Diagnostics.Process pipes = new System.Diagnostics.Process();
              pipes.EnableRaisingEvents = false;
              pipes.StartInfo.FileName = "rm -r /home/zaizeku/Desktop/test.txt";
              pipes.Start();

but it did not do anything, I'm really having a hard time finding a solution to this, so I ask you guys, can you help me figure this out, or tell me if its not possible.

Thanks in Advance



 « Return to Thread: Executing Shell commands