r/Tcl•
djhag

Newbie needs help parsing output and assigning to variables

Hoping someone can help me with this. It's probably an easy task for most of you but I can't seem to find the recipe via google.

I am logging into a box and running a command to generate an output. This gives me 1 or 2 lines of output, depending upon number of devices found, similar to:

edit "S124EPXXXXX1"

edit "S124EPXXXXX2"

Can anyone show me how to grab each S124EPXXXXXx string from the above output and assign each to its own variable in a TCL script? I just need a result something like:

$SW1 = S124EPXXXXX1

$SW2 = S124EPXXXXX2

I'm a pretty new with TCL, regex, etc. although I've been dabbling for a while.

Thanks

Posted Feb 22, 2022, 5:20 PM UTC

35
Loading comments…