很多太 ec2 机器 想通过 go 实现快速执行命令
搞了好久了 没成功
原始命令为 ssh -i '/f/Download/new aws.pem' [email protected] 'wc -l /home/e.csv'
package main
import (
"fmt"
"os/exec"
)
func main() {
args := []string{"-i '/f/Download/new aws.pem' [email protected]","wc -l /home/e.csv"}
cmd := exec.Command("ssh",args...)
ret,err := cmd.Output()
if err != nil {
fmt.Printf("\nerr:%v\n", err)
}
fmt.Printf("%v\n",ret)
}