//
// execute shell command
//
779144
func shellExec(command string) {
	args := args.GetArgs(command)
	if len(args) < 1 {
		fmt.Println("No command to exec")
	} else {
		if strings.ContainsAny(command, "$*~") {
			if _, err := exec.LookPath("sh"); err == nil {
				args = []string{"sh", "-c", command}
			}
		}
		cmd := exec.Command(args[0])
		cmd.Args = args
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr

		if err := cmd.Run(); err != nil {
			fmt.Println(err)
		}
	}
}
1100445
func Execute() {
	if err := FusisCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}
472464
func (cmd *command) Execute(ch io.ReadWriter) (err error) {
	if cmd.Flags.Source {
		err = cmd.serveSource(ch)
	} else {
		err = cmd.serveSink(ch)
	}
	if err != nil {
		if cmd.Config.RunOnServer == false {
			return trace.Wrap(err)
		} else {
			// when 'teleport scp' encounters an error, it SHOULD NOT be logged
			// to stderr (i.e. we should not return an error here) and instead
			// it should be sent back to scp client using scp protocol
			cmd.sendError(ch, err)
		}
	}
	return nil
}
455129
func (c *Client) Execute(cmd Command) error {
	return c.cluster.Execute(cmd)
}
1213746
func Execute() {
	if err := rootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
989251
func Command(v interface{}) (*exec.Cmd, error) {
	var cmd string
	var args []string

	if typeutil.IsEmpty(v) {
		return nil, fmt.Errorf("Cannot parse empty argument into *exec.Cmd")
	}

	if typeutil.IsKind(v, reflect.Struct) {
		if cmdargs, err := Parse(v); err == nil {
			cmd = cmdargs[0]
			args = cmdargs[1:]
		} else {
			return nil, err
		}
	} else if typeutil.IsKind(v, reflect.String) || typeutil.IsArray(v) {
		cmdargs := sliceutil.Stringify(sliceutil.Sliceify(v))

		if len(cmdargs) > 0 {
			cmd = cmdargs[0]
			args = cmdargs[1:]
		} else {
			return nil, fmt.Errorf("Cannot parse empty argument into *exec.Cmd")
		}
	} else {
		return nil, fmt.Errorf("Unexpected type: need struct, string, or []string, got: %T", v)
	}

	return exec.Command(cmd, args...), nil
}
740082
func (command *ServerCommand) Execute() error {
	var apiDocsDir string

	log.Infof("Generating a %v server", command.Language)

	if !command.NoAPIDocs {
		apiDocsDir = "apidocs"
	}

	cs := codegen.Server{
		RAMLFile:       command.RamlFile,
		Kind:           command.Kind,
		Dir:            command.Dir,
		PackageName:    command.PackageName,
		Lang:           command.Language,
		APIDocsDir:     apiDocsDir,
		RootImportPath: command.ImportPath,
		WithMain:       !command.NoMainGeneration,
		LibRootURLs:    strings.Split(command.LibRootURLs, ","),
	}
	return cs.Generate()
}
1330322
func (*localExecutor) Execute(command []string, in io.Reader, out, errOut io.Writer) error {
	klog.V(3).Infof("Local executor running command: %s", strings.Join(command, " "))
	cmd := exec.Command(command[0], command[1:]...)
	cmd.Stdout = out
	cmd.Stderr = errOut
	cmd.Stdin = in
	err := cmd.Run()
	if err != nil {
		klog.V(4).Infof("Error from local command execution: %v", err)
	}
	return err
}
631281
func Execute(v string) {
	version = v
	if err := rootCmd.Execute(); err != nil {
		log.Fatal(err)
	}
}
1330549
func (c *QueryRead) Execute(args []string) error {
	return c.doQueryOp(ShellQueryClient.Read, c.Args.EntityName, c.Args.Queries, 1)
}
500526
func Exec(program string, args ...string) ([]byte, error) {
	var b bytes.Buffer
	cmd := osexec.Command(program, args...)
	cmd.Stdout = &b
	cmd.Stderr = &b
	err := cmd.Run()
	if err != nil {
		err = fmt.Errorf("executing %s failed: %v", program, err)
	}
	return b.Bytes(), err
}
426804
func Execute(args ...string) int {
	cli := &cli.CLI{
		Args:     args,
		Commands: Commands,
		HelpFunc: cli.BasicHelpFunc("consul"),
	}

	exitCode, err := cli.Run()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
		return 1
	}

	return exitCode
}
382396
func (c *SocketConnection) Execute(command, args string, sync bool) (m *Message, err error) {
	return c.SendMsg(map[string]string{
		"call-command":     "execute",
		"execute-app-name": command,
		"execute-app-arg":  args,
		"event-lock":       strconv.FormatBool(sync),
	}, "", "")
}
1266554
func run(dir, command string, args ...string) (string, error) {
	logger.Debugf("(%s) %s %v", dir, command, args)

	cmd := exec.Command(command, args...)
	if dir != "" {
		cmd.Dir = dir
	}

	out, err := cmd.CombinedOutput()
	output := string(out)

	logger.Debugf("output: %v", output)
	return output, err
}
591786
func (command *CapnpCommand) Execute() error {
	var apiDef raml.APIDefinition

	command.Language = strings.ToLower(command.Language)
	if command.Language != "go" && command.Language != "plain" {
		return fmt.Errorf("canpnp generator only support plain & Go-compatible schema")
	}

	log.Debug("Generating capnp models")

	err := raml.ParseFile(command.RAMLFile, &apiDef)
	if err != nil {
		return err
	}
	return codegen.GenerateCapnp(&apiDef, command.Dir, command.Language, command.Package)
}
387433
func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error {
	if g.defaultCommandLineFlags {
		g.AddFlags(pflag.CommandLine)
		pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
		pflag.Parse()
	}

	b, err := g.NewBuilder()
	if err != nil {
		return fmt.Errorf("Failed making a parser: %v", err)
	}

	c, err := generator.NewContext(b, nameSystems, defaultSystem)
	if err != nil {
		return fmt.Errorf("Failed making a context: %v", err)
	}

	c.Verify = g.VerifyOnly
	packages := pkgs(c, g)
	if err := c.ExecutePackages(g.OutputBase, packages); err != nil {
		return fmt.Errorf("Failed executing generator: %v", err)
	}

	return nil
}
730938
func (c *Cluster) Execute(command Command) error {
	if command == nil {
		return ErrClusterCommandRequired
	}
	async := &Async{
		Command: command,
	}
	c.execute(async)
	if async.Error != nil {
		return async.Error
	}
	if cerr := command.Error(); cerr != nil {
		return cerr
	}
	return nil
}