-
Hello, Is there a way to pull information from the output of a show command to use in another command? For instance, say I needed to run the following commands:
If I needed the So what my end goal would be is to have something like this:
Is this possible? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, just get the result back from the first show command; parse the output to extract the interface. Then use some form of f-strings or .format() method to generate the next command using the interface you saved in the previous command. For parsing, you can look at regular expressions or just a straight .split() call and extract the first field. In other situations, you can use TextFSM or Genie, but those solutions probably won't work here. |
Beta Was this translation helpful? Give feedback.
Yes, just get the result back from the first show command; parse the output to extract the interface. Then use some form of f-strings or .format() method to generate the next command using the interface you saved in the previous command.
For parsing, you can look at regular expressions or just a straight .split() call and extract the first field. In other situations, you can use TextFSM or Genie, but those solutions probably won't work here.