Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with print format
#1
Hi All,

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?
Reply


Messages In This Thread
problem with print format - by anna - May-15-2018, 05:52 PM
RE: problem with print format - by nilamo - May-15-2018, 06:09 PM
RE: problem with print format - by anna - May-15-2018, 06:39 PM
RE: problem with print format - by killerrex - May-15-2018, 07:07 PM
RE: problem with print format - by anna - May-15-2018, 07:43 PM
RE: problem with print format - by killerrex - May-15-2018, 11:12 PM
RE: problem with print format - by anna - May-16-2018, 08:01 AM
RE: problem with print format - by anna - May-16-2018, 11:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with print command in super() akbarza 5 679 Feb-01-2024, 12:25 PM
Last Post: deanhystad
  problem with spliting line in print akbarza 3 445 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  problem with print lists MarekGwozdz 4 756 Dec-15-2023, 09:13 AM
Last Post: Pedroski55
  Problem with print variable in print.cell (fpdf) muconi 0 693 Dec-25-2022, 02:24 PM
Last Post: muconi
  Print first day of the week as string in date format MyerzzD 2 2,070 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  Fetch Oracle DB rows & print it in HTML file with table's col headers in table format tssr_2001 1 3,040 Sep-04-2020, 01:39 PM
Last Post: ibreeden
  C to Python code conversion print problem anakk1n 1 2,218 May-22-2020, 04:15 PM
Last Post: deanhystad
  Highscore problem, need to print top 5 Camiosobro123 5 4,966 Jan-29-2020, 03:31 PM
Last Post: ThiefOfTime
  Parquet format conversion problem Bilhardas 1 1,685 Nov-19-2019, 11:06 AM
Last Post: baquerik
  misunderstanding of format in print function Harvey 2 2,206 Oct-29-2019, 12:44 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020