Skip to content

Commit

Permalink
Migrating to the newer command method
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Feb 16, 2024
1 parent 2a27872 commit 44c6095
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions recorder/recorder_status.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"bufio"
"bytes"
"fmt"
"os/exec"
Expand All @@ -11,22 +10,20 @@ import (
)

func (v *Views) status(transporter commonTransporter.Transporter) (string, error) {
c := exec.Command("tail", "-n", "26", fmt.Sprintf("\"logs/%s.txt\"", transporter.Unique), "|", "sed", "-e", "\"s/\r$//\"")
cmd := exec.Command("tail", "-n", "26", fmt.Sprintf("/logs/%s.txt", transporter.Unique))

var stdout bytes.Buffer
c.Stdout = &stdout
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr

var errOut string

if err := c.Run(); err != nil {
err := cmd.Run()
if err != nil {
errOut = fmt.Sprintf("could not run command: %+v", err)
}

stderr, _ := c.StderrPipe()
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
errOut += "\n" + scanner.Text()
}
errOut += stderr.String()

if len(errOut) != 0 {
return "", fmt.Errorf(errOut)
Expand Down

0 comments on commit 44c6095

Please sign in to comment.