标签:word hosts sts pac lin nil com exp roo
package main
import (
"fmt"
"flag"
gexpect "github.com/ThomasRooney/gexpect"
)
func main() {
cmdStr := flag.String("cmd", "", "cmds")
hostStr := flag.String("host", "", "hoststr")
passwd := flag.String("p", "", "passwd")
flag.Parse()
command := "ssh -o ‘StrictHostKeyChecking no‘ -o ConnectTimeout=2 " + *hostStr + " -a " + *cmdStr
child, err := gexpect.Spawn(command)
if err != nil {
panic(err)
}
fmt.Println("-----")
child.Expect("password:")
child.SendLine(*passwd)
child.Interact()
child.Close()
}
标签:word hosts sts pac lin nil com exp roo
原文地址:https://www.cnblogs.com/ah-firelove/p/14336502.html