May-15-2018, 05:52 PM
Hi All,
I am not able to print multiple variable output on single line.
I am not able to print multiple variable output on single line.
import telnetlib HOST = "10.10.1.10" user = "test" password = "test@123" telnet = telnetlib.Telnet(HOST) #telnet.set_debuglevel(2) telnet.read_until("Username: ",3) telnet.write(user + "\n") if password: telnet.read_until("Password:",3) telnet.write(password + "\n") telnet.write("term len 0 \n") telnet.read_until(">") telnet.write("show ver \n") telnet.read_until(">") telnet.write("exit\n") output = telnet.read_all() for line in output.split('\n'): if 'Version' in line: Version = line.split(',')[1] if 'image' in line: Image = line.split(' ')[4] if ('Processor board ID') in line: ProcessorID = line.split(' ')[3] if 'MAC Address' in line: MACAddress = line.split(' ')[4] if ('Model number') in line: Model = line.split(':')[1] if 'System serial number' in line: SystemSerialNumber = line.split(':')[1] print HOST+" "+Version+" "+Image+" "+ProcessorID+" "+MACAddress+" "+Model+" "+SystemSerialNumber print('{} {} {} {} {} {} {}'.format(HOST,Version,Image,ProcessorID,MACAddress,Model,SystemSerialNumber))
Output: FOC0835X50K4-EI0ion 12.1(22)EA12 "flash:c2950-i6q4l2-mz.121-22.EA12.bin"
FOC0835X50K4-EI0ion 12.1(22)EA12 "flash:c2950-i6q4l2-mz.121-22.EA12.bin"
what could be the issue?