Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add to documentation how to get stderr from pipe.Command? #3

Open
denishonig opened this issue Oct 2, 2020 · 1 comment
Open

Comments

@denishonig
Copy link

No description provided.

@toudi
Copy link

toudi commented Oct 8, 2020

you could try it this way:

	stack := []*exec.Cmd{
		exec.Command("my-command-1"),
		exec.Command("my-command-2"),
               // ....
	}
	if err = Command(&b, stack...); err != nil {
		// grab stderr
		stderrBuff := stack[0].Stderr.(*bytes.Buffer)
		fmt.Printf("stderr contents: %s\n", i, stderrBuff.String())
		return "", err
	}

I'm not sure why doesn't it work all the time :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants