Skip to content

output stderr when running ssh commands #406

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yashsinghcodes
Copy link
Member

I added logic to return an error message if we get anything in stderr.

I'm unsure whether the result should be marked as success: false or true, since the SSH connection was successful, but the command execution on the remote shell failed.

Also yes, do let me know If I should also return the stdout if there is any when we actually return in this case?

This makes it easier for user to know what went wrong.

@frikky
Copy link
Member

frikky commented Apr 24, 2025

I added logic to return an error message if we get anything in stderr.

I'm unsure whether the result should be marked as success: false or true, since the SSH connection was successful, but the command execution on the remote shell failed.

Also yes, do let me know If I should also return the stdout if there is any when we actually return in this case?

This makes it easier for user to know what went wrong.

Don't return at that point at all, I'd say. STDOUT may still have data, so you just add it as an additional field to the same dictionary (e.g. error_logs).

@frikky
Copy link
Member

frikky commented Apr 30, 2025

bump

@yashsinghcodes
Copy link
Member Author

Hey, sorry — I was off last week. I've made the change.

Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(:

except Exception as e:
return {"success":"false","message":str(e)}

return {"success":"true","output": stdout.read().decode(errors='ignore')}
return {"success":"true","output": stdout.read().decode(errors='ignore'), "error_log": stderr.read().decode(errors='ignore')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't stderr.read() and stdout.read() be try-caught? Those can easily crash. The decode as well.

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

Successfully merging this pull request may close these issues.

2 participants