Skip to content

Commit

Permalink
Send stderr from script to log (#101)
Browse files Browse the repository at this point in the history
Fixes #99
  • Loading branch information
msoap authored Feb 10, 2024
1 parent 2bb7e4c commit f4f1945
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shell2http.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"context"
"flag"
"fmt"
Expand Down Expand Up @@ -243,8 +244,12 @@ func execShellCommand(appConfig Config, shell string, params []string, req *http
if appConfig.includeStderr {
shellOut, err = osExecCommand.CombinedOutput()
} else {
osExecCommand.Stderr = os.Stderr
var stderrBuf bytes.Buffer
osExecCommand.Stderr = &stderrBuf
shellOut, err = osExecCommand.Output()
if stderrBuf.Len() > 0 {
log.Printf("stderr: %s", stderrBuf.String())
}
}

if waitPipeWrite {
Expand Down

0 comments on commit f4f1945

Please sign in to comment.