import paramiko
import os
import re
username='user'
port=22
password='password'
hostname='127.0.0.1'
if __name__ == "__main__":
paramiko.util.log_to_file('paramiko.log')
s = paramiko.SSHClient()
s.load_system_host_keys()
s.connect(hostname, port, username, password)
stdin, stdout, stderr = s.exec_command('ifconfig')
d=stdout.read()
s.close()
for i in d.splitlines():
if "inet" in i:
s=re.search(r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}',i)
if s:
print (s.group())
import os
import re
username='user'
port=22
password='password'
hostname='127.0.0.1'
if __name__ == "__main__":
paramiko.util.log_to_file('paramiko.log')
s = paramiko.SSHClient()
s.load_system_host_keys()
s.connect(hostname, port, username, password)
stdin, stdout, stderr = s.exec_command('ifconfig')
d=stdout.read()
s.close()
for i in d.splitlines():
if "inet" in i:
s=re.search(r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}',i)
if s:
print (s.group())
No comments:
Post a Comment