proc pip {ips} { ;# The function pip is created with the variable ip foreach ip $ips { ;# For each value of the list created before running the script the do set output [exec "ping $ip"] ;# Puts in the variable "output" the return of the executed command ping with the ip variable inserted by the engineer puts "" ;# It doesn't print anything in the command line. These two lines run a ping but it doesn't print anythin on the screen append $ip " " ;# Append and space after the IP variable set output [exec "show arp | include $ip"] ;# Puts in the variable "output" the return of the executed command [show arp 1 includes $ip] with the ip variable inserted by the engineer set interF GigabitEthernet ;# Puts in the variable inertF the data "GigabitEthernet" set position [string first $interF $output] ;# Looks in the string saved in the variable "output" the first ocurrence of the variable interF; in other words it searches for the first ocurrence of the work GigabitEthernet on the ouput of the command "show arp | include $ip" and then saves this position on the variable "position" set length2 [expr $position + 21] ;# Puts on the variable "length" the length of the string "output" (of the output of the command "show arp 1 include $ip") puts -nonewline "IP Address: " ;# Prints on the screen without creating a new line the data "IP Address: " puts -nonewline $ip ;# Prints on the screen without creating a new line the $ip value puts -nonewline " " ;# Prints on the screen without creating a new line a space set output2 [string range $output $position $length2] ;# Puts on the variabe "ouput2" the values from the word GigabitEthernet until the end of the output puts -nonewline $output2 ;# Prints on the screen without creating a new line the value of output2 puts "" ;# Insert new line comment } } proc pip {ips} { foreach ip $ips { set output [exec "ping $ip"] puts "" append $ip " " set output [exec "show arp | include $ip "] set interF GigabitEthernet set position [string first $interF $output] set length2 [expr $position + 21] puts -nonewline "IP Address: " puts -nonewline $ip puts -nonewline " " set output2 [string range $output $position $length2] puts -nonewline $output2 puts "" } } ;#Running the command we have the following result: BOG-SUBAH-THBTVSUBA3#tclsh BOG-SUBAH-THBTVSUBA3(tcl)#(Paste the script here) BOG-SUBAH-THBTVSUBA3(tcl)#set mylist {172.17.20.2 172.17.20.34} #Here go all the IPs you want to search BOG-SUBAH-THBTVSUBA3(tcl)#pip $mylist IP Address: 172.17.20.2 GigabitEthernet10/23 IP Address: 172.17.20.34 GigabitEthernet1/5