Skip to content

Instantly share code, notes, and snippets.

@odewahn
Created March 1, 2016 23:01
Show Gist options
  • Save odewahn/3e756c215779b9f44cc9 to your computer and use it in GitHub Desktop.
Save odewahn/3e756c215779b9f44cc9 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os/exec"
"strings"
)
func runCmd(cmdArgs []string) ([]string, error) {
cmdName := "docker-machine"
cmdOut, err := exec.Command(cmdName, cmdArgs...).Output()
if err != nil {
return []string{""}, err
}
return strings.Split(string(cmdOut), "\n"), nil
}
func main() {
x, _ := runCmd([]string{"ip", "launchbot"})
fmt.Println(x[0])
x, _ = runCmd([]string{"ls"})
for _, c := range x {
//fmt.Println(c)
fields := strings.Fields(c)
if len(c) > 0 {
fmt.Println(fields[0], fields[2], fields[3])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment