diff options
| author | Jeff Carr <[email protected]> | 2019-05-10 02:46:27 +0000 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2019-05-10 02:46:27 +0000 |
| commit | 59c9bf88cace539461f451a318e79feddee8f502 (patch) | |
| tree | 22eb9b0035516157f48b6c0f18f7c7dfd2f666a3 /example1/main.go | |
| parent | 954470c34ce2296c4d534c261f400c4fa9f20900 (diff) | |
fix stderr (stdout was wrong too)
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'example1/main.go')
| -rw-r--r-- | example1/main.go | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/example1/main.go b/example1/main.go index 4a36503..be88ab4 100644 --- a/example1/main.go +++ b/example1/main.go @@ -3,24 +3,41 @@ package main /* import "log" import "reflect" -import "os" */ +import "os" + // import "github.com/davecgh/go-spew/spew" import "git.wit.com/jcarr/shell" func main() { - shell.SpewOn() shell.Run("ls /tmp") - shell.Run("ping -c 4 localhost") + shell.Run("ping -c 3 localhost") // slow down the polling to every 2 seconds shell.SetDelayInMsec(2000) + shell.Run("ping -c 4 localhost") + // capture ping output into a file + fout, _ := os.Create("/tmp/example1.ping.stdout") + ferr, _ := os.Create("/tmp/example1.ping.stderr") + shell.SetStdout(fout) + shell.SetStderr(ferr) + + shell.Run("ping -c 5 localhost") + + // turn out process exit debugging + shell.SpewOn() + + fout, _ = os.Create("/tmp/example1.fail.stdout") + ferr, _ = os.Create("/tmp/example1.fail.stderr") + shell.SetStdout(fout) + shell.SetStderr(ferr) + // TODO: this might not be working // check error handling shell.Run("ls /tmpthisisnothere") |
