cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2165
Views
0
Helpful
1
Replies

How to copy an IP-Address from CLI output into a variable?

Marc Bosecki
Cisco Employee
Cisco Employee

Hi,

Does anybody know how I can copy the IP address from an output from " ping www.cisco.com" into a variable?

"Sending 5, 100-byte ICMP Echos to 95.100.32.170, timeout is 2 seconds"

Thanks

Marc

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

If you mean using EEM, you cam do that using something like:

set output [cli_run [list "enable" "ping www.cisco.com"]]

if { [regexp {Echos to ([\d\.]+)} $output -> ip] } {

    puts "Address is $ip"

}

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: