also print STDERR to STDOUT
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
2fcc7947db
commit
8c2168f588
14
shell.go
14
shell.go
|
@ -125,7 +125,7 @@ func Run(cmdline string) string {
|
||||||
nbr := nbreader.NewNBReader(newreader, 1024)
|
nbr := nbreader.NewNBReader(newreader, 1024)
|
||||||
|
|
||||||
tmp := bufio.NewReader(pstderr)
|
tmp := bufio.NewReader(pstderr)
|
||||||
go NonBlockingReader(tmp, shellStderr)
|
go nonBlockingReader(tmp, shellStderr, f)
|
||||||
|
|
||||||
totalCount := 0
|
totalCount := 0
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ func Run(cmdline string) string {
|
||||||
oneByte = make([]byte, 1024)
|
oneByte = make([]byte, 1024)
|
||||||
count, err = nbr.Read(oneByte)
|
count, err = nbr.Read(oneByte)
|
||||||
log.Debug("STDOUT: count = ", count)
|
log.Debug("STDOUT: count = ", count)
|
||||||
if (! quiet) {
|
if (quiet == false) {
|
||||||
f.Write(oneByte[0:count])
|
f.Write(oneByte[0:count])
|
||||||
f.Flush()
|
f.Flush()
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ func Run(cmdline string) string {
|
||||||
} else {
|
} else {
|
||||||
log.Debug("STDOUT: count = ", count)
|
log.Debug("STDOUT: count = ", count)
|
||||||
io.WriteString(&bytesBuffer, string(oneByte))
|
io.WriteString(&bytesBuffer, string(oneByte))
|
||||||
if (! quiet) {
|
if (quiet == false) {
|
||||||
f.Write(oneByte[0:count])
|
f.Write(oneByte[0:count])
|
||||||
f.Flush()
|
f.Flush()
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,6 @@ func Run(cmdline string) string {
|
||||||
// stuff := err.(*exec.ExitError)
|
// stuff := err.(*exec.ExitError)
|
||||||
log.Debug("ERROR ", err.Error())
|
log.Debug("ERROR ", err.Error())
|
||||||
log.Debug("END ", cmdline)
|
log.Debug("END ", cmdline)
|
||||||
// return -1, "", fmt.Errorf(err.Error())
|
|
||||||
// handleError(fmt.Errorf(err.Error()), -1)
|
|
||||||
handleError(err, -1)
|
handleError(err, -1)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -216,7 +214,7 @@ func Daemon(cmdline string, timeout time.Duration) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass in two file handles (1 read, 1 write)
|
// pass in two file handles (1 read, 1 write)
|
||||||
func NonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File) {
|
func nonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File, stdout *bufio.Writer) {
|
||||||
// newreader := bufio.NewReader(readFileHandle)
|
// newreader := bufio.NewReader(readFileHandle)
|
||||||
|
|
||||||
// create a nonblocking GO reader
|
// create a nonblocking GO reader
|
||||||
|
@ -245,6 +243,10 @@ func NonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File) {
|
||||||
} else {
|
} else {
|
||||||
log.Debug("STDERR: count = ", count)
|
log.Debug("STDERR: count = ", count)
|
||||||
writeFileHandle.Write(oneByte[0:count])
|
writeFileHandle.Write(oneByte[0:count])
|
||||||
|
if (quiet == false) {
|
||||||
|
stdout.Write(oneByte[0:count])
|
||||||
|
stdout.Flush()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue