04-24-2025 08:55 AM
Hi,
I'm trying to survey the presence of a given entry in the c9800 wireless controller mdns cache. SNMP does not seem to forward this kind of information, neither does netconf. The last idea was to ssh the command, but bash scripts work when executed manually, but don't receive any reply from within a cron task (prabably because there is no terminal attached). Until now, suggestions from google search did not help...
04-24-2025 09:03 AM
After a lot of debugging, I found that the ssh issue from cron, not returning any result, can be observed only with "show mdns-sd cache" command. Instead, using "show mdns-sd" returns 'Line has invalid autocommand "show mdns-sd" ' and "show mdns-sd query-db" returns some text, but not really what I'm looking for...
04-27-2025 02:21 PM
What script were you running from cron?
Did you remember to issue "term len 0" before the show command?
04-28-2025 02:26 AM
Well, even the term command did not do the trick, changing the way of sending the command (almost) allowed me to get the text I wanted. Indeed,
ssh -l myuser mywlc 'show mdns-sd cache' does not work, but
ssh -l myuser mywlc <<EOT | grep -v "mywlc"
show mdns-sd cache
EOT
did it... Probably the command is not considered to be an autocommand anymore...
Note that the last grep -v is needed in order to suppress remote prompt and the echoed command from the final result...
04-28-2025 02:37 AM
Yes I would not expect that to work well. You'd either have to write it as an expect or python script or use some other custom scripting tool designed to work which allows this type of interactive result from network devices.
https://www.geeksforgeeks.org/expect-command-in-linux-with-examples/
https://www.digitalocean.com/community/tutorials/expect-script-ssh-example-tutorial
https://phoenixnap.com/kb/linux-expect
https://developer.cisco.com/codeexchange/github/repo/CiscoDevNet/python_code_samples_network/
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