[Mono-list] using piep with Process

Leonel Florin Selles leonel06013 at cfg.jovenclub.cu
Fri Apr 15 16:33:03 EDT 2011


Hi, here I'm again:

Well, now I want to execute this Linux shell command "users | wc -w",
through this I get the numbers of users that are using the system, for
example, if there are the user "Florin" and "root" logged, that command
will give me the number 2, and if your see the command "users" return the
list

florin root

and using pipe (|) I send this list to "wc -w", which count the numbers of
words.

Now, using Process in C# I got this

System.Diagnostics.ProcessStartInfo commandDetails = new
System.Diagnostics.ProcessStartInfo ("users | wc -w");
			commandDetails.UseShellExecute = false;
			commandDetails.RedirectStandardOutput = true;

			System.Diagnostics.Process command = System.Diagnostics.Process.Start
(commandDetails);

			string numberOfUser = command.StandardOutput.ReadToEnd ();



but when I execute the program I realize that I'm executing two command in
one, there are any choose to use a pipe.




____________________________________________
Algunos suelen hayar su destino en el sendero que toman para evitarlo.
____________________________________________
Tu mente es como el agua, cuando esta agitada se vuelve dificir ver, pero
si dejas que se calme, la respuesta se vuelve clara.
____________________________________________
El ayer es historia, el mañana es un misterio, pero el hoy es un obcequio,
por eso se llama presente.



More information about the Mono-list mailing list