SSH client with identities support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package main
  2. import (
  3. "bytes"
  4. "fmt"
  5. "os"
  6. "os/exec"
  7. "regexp"
  8. )
  9. func fatal(err error) {
  10. if err == nil {
  11. return
  12. }
  13. fmt.Fprintf(os.Stderr, "%s\n", err.Error())
  14. os.Exit(-1)
  15. }
  16. func matchParams(re *regexp.Regexp, str string) map[string]string {
  17. match := re.FindStringSubmatch(str)
  18. if match == nil {
  19. return nil
  20. }
  21. params := make(map[string]string)
  22. for i, name := range re.SubexpNames() {
  23. params[name] = match[i]
  24. }
  25. return params
  26. }
  27. func capture3(cmd *exec.Cmd) ([]byte, []byte, error) {
  28. var stdout, stderr bytes.Buffer
  29. cmd.Stdout = &stdout
  30. cmd.Stderr = &stderr
  31. err := cmd.Run()
  32. return stdout.Bytes(), stderr.Bytes(), err
  33. }
  34. func dumpEnv(env []string) {
  35. for _, e := range env {
  36. fmt.Println(e)
  37. }
  38. }