#!/usr/bin/env python #-*- encoding:utf-8 -*- import paramiko transport = paramiko.Transport(('10.34.1.18', 22)) transport.connect(username='ahwater', password='Aa7788..') ssh = paramiko.SSHClient() ssh._transport = transport cmd04='wmic memorychip get capacity' stdin,stdout,stderr = ssh.exec_command(cmd04) da04=stdout.read().strip('Capacity').replace(' ','').replace('\t','').replace('\r','').strip() da004=(' '.join(filter(lambda x: x, da04.split(' ')))) da005=da04.split('\n') print da005 #data04=int(da04)/1024/1024/1024 #print da005[1],da005[2] couns=0 for i in da005: lens=len(da005) #print(lens) #if lens % 2 == 0: couns = couns + int(i) #lens=lens - 1 print couns #print("mem total Gb: ",data04)