analylx
4/27/2017 - 12:29 PM

get_ifconfig.py

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("200.200.180.58", 22, "root", "root")

stdin, stdout, stderr = ssh.exec_command("ifconfig")
#Time = str(ssh.exec_command("date"))
#print(Time)
records = stdout.readlines()
#print records
# the result:   ['/home/fs\n']

stdin, stdout, stderr = ssh.exec_command("ls")
#print records

f = open('infoTieba.txt', 'a')

for each in records:
   try:
      f.write(str(each)+ '\n')
   except:
      pass
f.close()