From 78fe4cbb3eddb166f0bf6a52299e3e37c5761deb Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Thu, 30 May 2019 02:42:34 -0400 Subject: using logged in user script rather than who|awk --- main.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index f5b1e05..fabfa43 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "encoding/json" "flag" "fmt" - "io" "io/ioutil" "log" "os" @@ -146,23 +145,11 @@ func main() { if strings.HasPrefix(e.Last(), "!users") { // execs: who -q | awk 'NR==1' // then saves the output to bytestream - who := exec.Command("who", "-q") - awk := exec.Command("awk", "NR==1") - r, w := io.Pipe() - who.Stdout = w - awk.Stdin = r + who := exec.Command("/usr/local/bin/showwhoison", "") var bytestream bytes.Buffer - awk.Stdout = &bytestream - err := who.Start() + who.Stdout = &bytestream + err := who.Run() checkerr(err) - err = awk.Start() - checkerr(err) - err = who.Wait() - checkerr(err) - w.Close() - err = awk.Wait() - checkerr(err) - r.Close() c.Cmd.Reply(e, "Check your private messages!") c.Cmd.Message(e.Source.Name, bytestream.String()) -- cgit 1.4.1-2-gfad0