sqshq/sampler · error
failed to execute command: %s
Error message
failed to execute command: %s
What it means
The basic interactive shell wraps any error from starting or communicating with the underlying command (cmd.Start / related exec calls) into "failed to execute command: <underlying error>". After repeated failures beyond errorThreshold, the library also drops the cached shell (item.basicShell = nil) so a fresh session is started next time. The root cause is always in the wrapped err string.
Source
Thrown at data/int_basic.go:93
}
return nil
}
func (s *BasicInteractiveShell) execute() (string, error) {
if s.stdin == nil {
return "", nil
}
_, err := io.WriteString(s.stdin, fmt.Sprintf(" %s\n", s.item.sampleScript))
if err != nil {
s.errCount++
if s.errCount > errorThreshold {
_ = s.cmd.Wait()
s.item.basicShell = nil // restart session
}
return "", fmt.Errorf("failed to execute command: %s", err)
}
timeout := make(chan bool, 1)
go func() {
time.Sleep(s.timeout)
timeout <- true
}()
var resultText strings.Builder
var errorText strings.Builder
for {
select {
case stdout := <-s.stdoutCh:
if len(stdout) > 0 {
resultText.WriteString(stdout)
resultText.WriteString("\n")View on GitHub (pinned to 9bc7ba732d)
Solutions
- Read the wrapped underlying error (after the colon) and fix that cause first (PATH, binary name, permissions)
- Use an absolute path to the executable in the item configuration
- Verify the command runs under the same user/environment the collector runs as (echo $PATH)
- Check the working directory and file permissions if the error mentions chdir or permission denied
Example fix
// before script: myscript.sh // after script: /opt/scripts/myscript.sh # absolute path, chmod +x applied
Defensive patterns
Strategy: try-catch
Validate before calling
path, err := exec.LookPath(cmdName)
if err != nil { return fmt.Errorf("command %q not found in PATH", cmdName) } Try / catch
out, err := shell.execute()
var execErr *exec.Error
if err != nil {
if errors.As(err, &execErr) {
log.Fatalf("fix PATH or binary name: %v", execErr)
}
return err
} Prevention
- Use absolute executable paths in item configs
- Verify the collector's runtime user/environment can see the binary
- Smoke-test commands with the exact service account
When it happens
Trigger: cmd.Start fails when running a command through the basic interactive shell — e.g. executable not on PATH, bad working directory, missing binary permissions — or repeated session errors tripping errorThreshold and forcing a session restart.
Common situations: Typo'd or missing command name in the item config; command present interactively but not in the collector's PATH (cron/systemd environments); script without execute bit; cwd removed.
Related errors
- failed to execute command: %s
- errorText.String()
- PTY mode is not supported on Windows
- panic(err)
- Failed to load the font:
AI-assisted analysis of sqshq/sampler@9bc7ba732d (2026-09-06).
Data as JSON: /api/errors/4ec8ce75593387bd.
Report an issue: GitHub.