// Script is the script to run.
500686
func (a *BucketSelectorAggregation) Script(script *Script) *BucketSelectorAggregation {
	a.script = script
	return a
}
1103255
func ExecuteScript(cfg abcconfig.DBConfig, script []byte) error {
	rdr := bytes.NewReader(script)

	if cfg.DB == "postgres" {
		passFilePath, err := pgPassFile(cfg)
		if err != nil {
			return err
		}
		defer os.Remove(passFilePath)

		cmd := exec.Command("psql", cfg.DBName, "-v", "ON_ERROR_STOP=1")
		cmd.Stdin = rdr
		cmd.Env = append(os.Environ(), pgEnv(cfg, passFilePath)...)

		res, err := cmd.CombinedOutput()
		if err != nil {
			fmt.Printf(string(res))
		}

		return err
	} else if cfg.DB == "mysql" {
		passFile, err := mysqlPassFile(cfg)
		if err != nil {
			return err
		}
		defer os.Remove(passFile)

		cmd := exec.Command("mysql", fmt.Sprintf("--defaults-file=%s", passFile), "--database", cfg.DBName)
		cmd.Stdin = rdr

		res, err := cmd.CombinedOutput()
		if err != nil {
			fmt.Println(string(res))
		}

		return err
	}

	return fmt.Errorf("cannot execute sql script, incompatible database %q", cfg.DB)
}
1323623
func (b *UpdateService) ScriptFile(scriptFile string) *UpdateService {
	b.scriptFile = scriptFile
	return b
}
927686
func (c *Client) ScriptLoad(script string) (string, error) {
	v, err := c.execOnFirst(true, "SCRIPT", "LOAD", script)
	if err != nil {
		return "", err
	}
	return iface2str(v)
}
607537
func (vm *Engine) subScript() []parsedOpcode {
	return vm.scripts[vm.scriptIdx][vm.lastCodeSep:]
}
880285
func (obj *Doc) GetScript(ctx context.Context) (string, error) {
	result := &struct {
		Script string	`json:"qScript"`
	} {}
	err := obj.rpc(ctx, "GetScript", result)
	return result.Script, err 
}
436700
func (s *SearchSource) ScriptField(scriptField *ScriptField) *SearchSource {
	s.scriptFields = append(s.scriptFields, scriptField)
	return s
}
633196
func (b *UpdateService) ScriptId(scriptId string) *UpdateService {
	b.scriptId = scriptId
	return b
}
574687
func (s *Script) Source() (interface{}, error) {
	if s.typ == "" && s.lang == "" && len(s.params) == 0 {
		return s.script, nil
	}
	source := make(map[string]interface{})
	// Beginning with 6.0, the type can only be "source" or "id"
	if s.typ == "" || s.typ == "inline" {
		src, err := s.rawScriptSource(s.script)
		if err != nil {
			return nil, err
		}
		source["source"] = src
	} else {
		source["id"] = s.script
	}
	if s.lang != "" {
		source["lang"] = s.lang
	}
	if len(s.params) > 0 {
		source["params"] = s.params
	}
	return source, nil
}
679987
func (sm *ScriptMap) Add(scriptName string, script *Script) {
	sm.lock.Lock()
	defer sm.lock.Unlock()
	sm.scripts[scriptName] = script
}
1052860
func ExecScript(script string) (*exec.Cmd, error) {
	var shell, flag string
	if runtime.GOOS == "windows" {
		shell = "cmd"
		flag = "/C"
	} else {
		shell = "/bin/sh"
		flag = "-c"
	}
	if other := os.Getenv("SHELL"); other != "" {
		shell = other
	}
	cmd := exec.Command(shell, flag, script)
	return cmd, nil
}
71931
func (u *Upstart) CreateScript() string {
	content := []string{"# Upstart script generated by github.com/dynport/dgtk/goup"}

	content = u.setDescription(content)
	content = u.setStartEvents(content)
	content = u.setStopEvents(content)

	content = u.setWorkingDirectory(content)
	content = u.setEnvironment(content)
	content = u.setExports(content)

	content = u.setExecAndScript(content)
	content = u.setStartClosure(content)
	content = u.setStopClosure(content)

	return strings.Join(content, "\n") + "\n"
}
293362
func (s *GetPlanOutput) SetPythonScript(v string) *GetPlanOutput {
	s.PythonScript = &v
	return s
}
1026173
func (h Helper) RunScriptCommand() (*command.Model, error) {
	tmpDir, err := h.ensureTmpDir()
	if err != nil {
		return nil, err
	}

	rubyScriptPth := path.Join(tmpDir, "script.rb")
	if err := fileutil.WriteStringToFile(rubyScriptPth, h.scriptContent); err != nil {
		return nil, err
	}

	var cmd *command.Model
	if h.gemfilePth != "" {
		cmd = command.New("bundle", "exec", "ruby", rubyScriptPth)
		cmd.AppendEnvs("BUNDLE_GEMFILE=" + h.gemfilePth)
	} else {
		cmd = command.New("ruby", rubyScriptPth)
	}

	return cmd, nil
}
206012
func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (script string, err error) {
	var result params.ProvisioningScriptResult
	if err = c.facade.FacadeCall("ProvisioningScript", args, &result); err != nil {
		return "", err
	}
	return result.Script, nil
}
1087607
func (cfg *cloudConfig) AddScripts(script ...string) {
	for _, line := range script {
		cfg.AddRunCmd(line)
	}
}
580194
func ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.SysProcAttr,
	name string, args []string) ([]byte, int, error) {
	cmd := exec.CommandContext(ctx, name, args...)

	// Copy runtime environment from the main command
	cmd.SysProcAttr = attrs
	cmd.Dir = dir
	cmd.Env = env

	// Capture output
	buf, _ := circbuf.NewBuffer(int64(drivers.CheckBufSize))
	cmd.Stdout = buf
	cmd.Stderr = buf

	if err := cmd.Run(); err != nil {
		exitErr, ok := err.(*exec.ExitError)
		if !ok {
			// Non-exit error, return it and let the caller treat
			// it as a critical failure
			return nil, 0, err
		}

		// Some kind of error happened; default to critical
		exitCode := 2
		if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
			exitCode = status.ExitStatus()
		}

		// Don't return the exitError as the caller only needs the
		// output and code.
		return buf.Bytes(), exitCode, nil
	}
	return buf.Bytes(), 0, nil
}