43 lines
817 B
Go
43 lines
817 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"strconv"
|
|
)
|
|
|
|
func getProcessOwner() string {
|
|
stdout, err := exec.Command("ps", "-o", "user=", "-p", strconv.Itoa(os.Getpid())).Output()
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
return string(stdout)
|
|
}
|
|
|
|
func StripSlice(slice []string, element string) []string {
|
|
for i := 0; i < len(slice); {
|
|
if slice[i] == element && i != len(slice)-1 {
|
|
slice = append(slice[:i], slice[i+1:]...)
|
|
} else if slice[i] == element && i == len(slice)-1 {
|
|
slice = slice[:i]
|
|
} else {
|
|
i++
|
|
}
|
|
}
|
|
return slice
|
|
}
|
|
|
|
func SubProcess(args []string) *exec.Cmd {
|
|
cmd := exec.Command(args[0], args[1:]...)
|
|
cmd.Stdin = os.Stdin
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
err := cmd.Start()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "[-] Error: %s\n", err)
|
|
}
|
|
return cmd
|
|
}
|