blob: be88ab4680296c1d28ca1c1f2a70ba1bb03ca142 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package main
/*
import "log"
import "reflect"
*/
import "os"
// import "github.com/davecgh/go-spew/spew"
import "git.wit.com/jcarr/shell"
func main() {
shell.Run("ls /tmp")
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")
}
|