Skip to content

Commit f4f1945

Browse files
authored
Send stderr from script to log (#101)
Fixes #99
1 parent 2bb7e4c commit f4f1945

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

shell2http.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bytes"
45
"context"
56
"flag"
67
"fmt"
@@ -243,8 +244,12 @@ func execShellCommand(appConfig Config, shell string, params []string, req *http
243244
if appConfig.includeStderr {
244245
shellOut, err = osExecCommand.CombinedOutput()
245246
} else {
246-
osExecCommand.Stderr = os.Stderr
247+
var stderrBuf bytes.Buffer
248+
osExecCommand.Stderr = &stderrBuf
247249
shellOut, err = osExecCommand.Output()
250+
if stderrBuf.Len() > 0 {
251+
log.Printf("stderr: %s", stderrBuf.String())
252+
}
248253
}
249254

250255
if waitPipeWrite {

0 commit comments

Comments
 (0)