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.

45 lines
721 B

package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"regexp"
)
func fatal(err error) {
if err == nil {
return
}
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(-1)
}
func matchParams(re *regexp.Regexp, str string) map[string]string {
match := re.FindStringSubmatch(str)
if match == nil {
return nil
}
params := make(map[string]string)
for i, name := range re.SubexpNames() {
params[name] = match[i]
}
return params
}
func capture3(cmd *exec.Cmd) ([]byte, []byte, error) {
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
return stdout.Bytes(), stderr.Bytes(), err
}
func dumpEnv(env []string) {
for _, e := range env {
fmt.Println(e)
}
}