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.

Abhi
  • 115
  • 1
  • 6

1 Answers1

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

starenka
  • 580
  • 3
  • 9
  • but does the same thing applied to sudo as well – Abhi Feb 04 '12 at 12:55
  • 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 – Abhi Feb 04 '12 at 13:00