Skip to content

Instantly share code, notes, and snippets.

@thomasdegry
Last active August 29, 2015 14:18
Show Gist options
  • Save thomasdegry/e22e2275d96762182e56 to your computer and use it in GitHub Desktop.
Save thomasdegry/e22e2275d96762182e56 to your computer and use it in GitHub Desktop.
Exit code
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
takePhoto()
}
func takePhoto() {
cmd := exec.Command("./photo.sh")
output, err := cmd.Output()
if _, ok := err.(*exec.ExitError); ok {
log.Println("command ran but exit status wasn't 0", err)
exec.Command("./kill-camera.sh")
return
}
fmt.Println(output)
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment