02-09-2018 07:54 AM - edited 03-01-2019 06:23 PM
Hello experts,
I'm trying to figure it out a way that I can manipulate an output in a way that I can store 2 variables, here's my output:
SW-CLOSET_3-100#show cts interface summary | in MANUAL
Te5/2 MANUAL OPEN unknown unknown invalid Invalid
Te6/2 MANUAL OPEN unknown unknown invalid Invalid
SW-CLOSET_3-100#
I need to grab Te5/2 and Te6/2 from that output since I need to make some configurations after the device reloads since I have a BUG that everytime that these devices (Catalyst 9400) reload CTS fails so I need to remove CTS and re-apply it back.
I have another example where I'm trying to manipulate a big output:
RTR_CISCO#ssh sshmyip.com
Translating "sshmyip.com"...domain server (8.8.8.8) [OK]
{
"comment": "## Your IP Address is XXX.XXX.XXX.XXX (43683) ##",
"family": "ipv4",
"ip": "XXX.XXX.XXX.XXX",
"port": "43683",
"protocol": "ssh",
"version": "v1.0.0",
"website": "https://github.com/packetsar/checkmyip"
}
[Connection to sshmyip.com closed by foreign host]
RTR_CISCO#
I'm using this output to build another EEM that works with DDNS on a DMZ area, but I have no idea how to just grab the IP part.
Any ideas on both solutions???
Thanks as always and appreciate the time that you take to read my post.
02-21-2018 09:51 AM
Joe,
After reviewing the whole thing I validate that I don't need to update with a specific IP since automatically the http will receive the public IP so I'm trying to make a TCL quite simple but I'm not sure how to do it, if I use tclsh to test everything works fine but I'm not sure how to translate the tclsh to the tcl Scrip, for example, if I go to the tclsh I can update my no-ip.com address:
WS-C3560CG(tcl)#set result [exec {more http://user:password@dynupdate.no-ip.com/nic/update?hostname=fqdn}]
good X.X.X.X
WS-C3560CG(tcl)#
Where the user, password and fqdn are my account values (the ones that I use to validate my user and fqdn) and X.X.X.X is the public IP address.
So my question is how to translate this tclsh to the tcl script: set result [exec {more http://user:password@dynupdate.no-ip.com/nic/update?hostname=fqdn}] every 4 hours and every time the router is reloaded?
Also, I needed to type Ctrl+V then ? to be able to paste the question mark.
Thanks and appreciate it
02-22-2018 06:24 AM
You can either do the same CLI within EEM+Tcl (you already have examples of CLI) or you can do what I suggested in order to modify your URL, correct the get_url usage, and use the http client library without any CLI interaction.
02-23-2018 08:09 AM
Thanks Joe for all your help. I figure it how to sent the ? for my ddns query, here's the final output:
event manager applet ddns authorization bypass
event none
action 010 set noip "http://user:password@dynupdate.no-ip.com/nic/update\x16"
action 020 append noip "\x3f"
action 025 append noip "hostname=fqdn"
action 030 puts "$noip"
action 035 cli command "enable"
action 040 cli command "more $noip"
From the debug I can see now the query:
WS-C3560CG#%HA_EM-6-LOG: ddns : DEBUG(cli_lib) : : IN : WS-C3560CG#more http://user:pass@dynupdate.no-ip.com/nic/update?hostname=fqdn
Feb 23 11:00:56.904 ET: %HA_EM-6-LOG: ddns : DEBUG(cli_lib) : : OUT : good <PUBLIC IP>
Feb 23 11:00:56.904 ET: %HA_EM-6-LOG: ddns : DEBUG(cli_lib) : : OUT :
Feb 23 11:00:56.904 ET: %HA_EM-6-LOG: ddns : DEBUG(cli_lib) : : OUT : WS-C3560CG#
Feb 23 11:00:56.904 ET: %HA_EM-6-LOG: ddns : DEBUG(cli_lib) : : CTL : cli_close called.
I really appreciate all your help.
Regards
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide