Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from paramiko import SSHClient
- import paramiko
- class SSH:
- def __init__(self):
- self.ssh = SSHClient()
- self.ssh.load_system_host_keys()
- self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- self.ssh.connect(hostname='blhp0032.locaweb.com.br',username='Administrator',password='SenhaServidor')
- def exec_cmd(self,cmd):
- stdin,stdout,stderr = self.ssh.exec_command(cmd)
- if stderr.channel.recv_exit_status() != 0:
- print stderr.read()
- else:
- print stdout.read()
- if __name__ == '__main__':
- ssh = SSH()
- ssh.exec_cmd("update image force http://firmware.tecnologia.ws/firmware/hpoa485.bin")
- #!/usr/bin/python
- from paramiko import SSHClient
- import paramiko
- import sys
- class SSH:
- def processar(ip):
- def __init__(self):
- self.ssh = SSHClient()
- self.ssh.load_system_host_keys()
- self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- self.ssh.connect(hostname=ip,username='Administrator',password='SenhaServidor')
- def exec_cmd(self,cmd):
- stdin,stdout,stderr = self.ssh.exec_command(cmd)
- if stderr.channel.recv_exit_status() != 0:
- print stderr.read()
- else:
- print stdout.read()
- if __name__ == '__main__':
- ssh = SSH()
- ssh.exec_cmd("update image force http://firmware.tecnologia.ws/firmware/hpoa485.bin")
- if __name__ == "__main__":
- for ip in sys.argv[1:]:
- processar(ip)
- Traceback (most recent call last):
- File "update_oa_teste.py", line 24, in <module>
- ssh.exec_cmd("update image force http://firmware.tecnologia.ws/firmware/hpoa485.bin")
- AttributeError: SSH instance has no attribute 'exec_cmd'
Add Comment
Please, Sign In to add comment