On a Cisco 2911 terminal server, if I run the command show line, it will present info about the console ports like this:

0/0/0    3 TTY   9600/9600  -    -      3    -    -   116    162  671/0       -
0/0/1    4 TTY   9600/9600  -    -      4    -    -    84    128    0/0       -     
0/0/2    5 TTY 115200/115200-    -      5    -    -    90 332670 28661/0      -
0/0/3    6 TTY 115200/115200-    -      6    -    -    76 332664 28180/0      -

What I would like is to see the "Location" parameter displayed alongside all the lines. Right now, I can view it by looking at the details of an individual line like show line 0/0/1, but I'd like to be able to pull the parameter for all the lines at once. Is there a way to do this in IOS?

  • I accepted @user208145's answer since it's correct, there isn't a way without using some other tool. However, his suggestion of using telnetlib, shogo2022's suggestion of using tcl are good approaches. I ended up using a Python script with netmiko and textfsm, then found the ntc-ansible Ansible modules that use the same textfsm modules, but handle all the connection logic and concurrency for you. – garettmd Jan 25 '19 at 19:26

I'm on a 3560 switch.

Cisco IOS Software, C3560 Software (C3560-IPBASE-M), Version
12.2(25)SEE2, RELEASE SOFTWARE (fc1)

Switch   Ports  Model              SW Version              SW Image
------   -----  -----              ----------              ----------
*    1   28     WS-C3560G-24PS     12.2(25)SEE2            C3560-IPBASE-M

If I use show line I get the output you described, as well as the verbose info when I use show line X. The show line ? help indicates a first and last int number can be used to get a range, but again it only displays that summary table.

#sh line ?
  <0-16>   First Line range
  console  Primary terminal line
  summary  Quick line status summary
  vty      Virtual terminal
  |        Output modifiers

If I were a magic 8 ball, I'd say all signs point to no, it's not possible.

Is this something you would be comfortable scripting? I've used Python's telnetlib library to automate getting switch health stats. I read that Expect can do this too, but I haven't used that.

  • I could script it out using netmiko, but since it's going to issue 64 commands on one terminal server (it has 64 console ports defined), and I have 20+ terminal servers to hit, it's going to take a while to gather all the data – garettmd Sep 28 '17 at 12:09

Another way to achieve this is the tcl. I don't have the cisco unit at hand and cannot try, but the code should be something like this.


    set lines [ exec "show line" ]
    foreach intf [ regexp -all -line -inline {[0-9]\/[0-9]\/[0-9]+.} $lines ] { 
    set detail [ exec "show line $intf" ]
    regexp {.*Location: (.*)\,} $detail location
    puts "$intf : $location"


If you have full control on the router, you can save this script and you can simply run it.

  • I'll check this out on Monday. Didn't know TCL was available on these devices – garettmd Oct 8 '17 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.