Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Cisco Employee

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

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
Cisco Employee

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

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"

}

931
Views
0
Helpful
1
Replies
CreatePlease to create content