« Return to Thread: Executing Shell commands

Re: Executing Shell commands

by Zaizeku :: Rate this Message:

Reply to Author | View in Thread


Matt Guo wrote:
Hey, Zaizeku,

The "rm" is the command, and the "-r /home/zaizeku/Desktop/test.txt"
is the arguments.

So following code shall be work:

...
pipes.StartInfo.FileName = "rm";
pipes.StartInfo.Arguments = "-r /home/zaizeku/Desktop/test.txt";
...

Moreover, if you want to execute a complex command, I think "sh" (i.e.
/usr/bin/sh) would be better than "gnome-terminal",
and  the code would be:

...
Process pipes = new Process();
string command = "rm -r /home/zaizeku/Desktop/test.txt";
string tmpScript = "/tmp/cmd.txt";
File.WriteAllText(tmpScript , command);
pipes.StartInfo.FileName = "sh";
pipes.StartInfo.Arguments = tmpScript ;
pipes.Start();
...

BTW,  ur question is not related to gtk-sharp, I think the mono
mail-list is a better place to ask such question.

B.R.
Matt
Thank you so much you solved my problem, and sorry I thought the question was relevant here, well anyway thanks for taking your time to actually answer my question I really appreciate it =)

 « Return to Thread: Executing Shell commands