0

I need a python lib to execute ssh command. I also need the output.

I tried paramiko: It was exactly what i needed but no way to execute sudo commands there. there are some online posts for that but none seem to work.

I also tried fabric: The problem is there is no way to capture output also sometimes it shows error while setting env.

Can anybody suggest something. A example of exec some sudo cmd over ssh will be good enough.

1 Answer 1

1

Fabric's operation.run captures stdout and also stderr if you pass combine_stderr to run(). See http://docs.fabfile.org/en/1.3.4/api/core/operations.html#fabric.operations.run

Sign up to request clarification or add additional context in comments.

2 Comments

but does the same thing applied to sudo as well
and also can you tell me how to use sudo in fabric cause when I do env.hosts= ['user@hosts', ] and env.passwords={'user@host': 'password'} then it doesn t works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.