Working on setting up an EC2 instance with boto, and after the initial boot, I'm going to ssh to the new instance and setup my environment. So, I can use Python or Go, so here's an example of using go to script shell commands from the golang-nuts group
package main
import (
"fmt"
"exec"
"bytes"
)
func main() {
cmd := "/bin/sh"
args := []string{cmd, "-c", "ls passwd"}
dir := "/etc"
p, err := exec.Run(cmd, args, nil, dir,
exec.DevNull, exec.Pipe, exec.PassThrough)
if err != nil {
return
}
var b bytes.Buffer
_, err = b.ReadFrom(p.Stdout)
if err != nil {
return
}
err = p.Close()
if err != nil {
return
}
fmt.Println(b.String())
}