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

Exit with ssh command's exit code #1

Open
solution-al opened this issue Feb 1, 2021 · 3 comments
Open

Exit with ssh command's exit code #1

solution-al opened this issue Feb 1, 2021 · 3 comments

Comments

@solution-al
Copy link

We have multiple hosts with executing long running tasks having a lot of output. We would like to exit dssh with non-zero exit code if any of the commands failed with non-zero exit code.

For example:

dssh -l "server1 server2" "invalid-command"
echo $?

Output of $? should be non-zero as is with running regular ssh:

ssh server1 "invalid-command"
echo $?

This is needed so that we could check for it and exit out wrapper script with non-zero exit code to hint that we should check logs to understand what went wrong in which server. Since currently dssh exits with code 0 it's impossible to do that.

@malensek
Copy link
Owner

Hmm, that's a great point. It probably wouldn't be much of an issue to fix this, either. Let me take a look...

@solution-al
Copy link
Author

We ran into the issue described above where one of the commands failed on one of the servers and we didn't notice it since dssh exit code was 0. Did you have time to look into this issue yet so that this problem would be fixed?

malensek added a commit that referenced this issue Mar 19, 2021
Attempts to address #1. Exit statuses are captured and written to a
temporary location (or optionally a user-specified file). We somewhat
arbitrarily return the highest-numbered exit status, with the intent to
avoid returning "0" (since that would signal everything worked as
expected).
@malensek
Copy link
Owner

I pushed a potential fix for this to the 'exit-status' branch... Haven't tested it much yet, but it should propagate the exit statuses and give you a non-zero result if any of the commands returned a non-zero exit code.

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