func principal() {
r1, w1 := io.Pipe()
var cmds = []*exec.Cmd{
exec.Command(“ls”, “-l”),
exec.Command(“ps”, “-A”),
}
cmds[1].Stdin, cmds[0].Stdout = r1, w1
cmds[1].Stdout = os.Stdout
if err := cmds[0].Begin(); err != nil {
fmt.Println(err)
return
}
if err := cmds[1].Begin(); err != nil {
fmt.Println(err)
return
}
cmds[1].Run()
cmds[0].Run()
}
Hello, @siquency, welcome to the discussion board. What are you attempting to kind these processes by?
from a to z and z to a
by PID from 1…N and vice versa
the consumer should wrote in terminal whicj kind he want
Hope you do that
It’s unlikely that anybody on this web site will write a whole program that solves your entire drawback and provides it to you. There are different internet sites the place you may pay folks to try this for you, however the aim of the members on this web site is to assist information you so you may remedy the issue (largely) your self.
That being stated,
Is there any cause you’re parsing the textual content output of ls
as a substitute of utilizing built-in features like (*os.File).Readdirnames
or utilizing a library like GitHub – shirou/gopsutil: psutil for golang as a substitute of parsing the output of ps
?
I need assistance with find out how to write the output of those processes into an array and find out how to kind them