Limiting the tables and using lindex in commands regexp

Hello

Here's my second and extremely crap question/post in what concerns the EEM/TCL.  I did some research on Google and have not really been able to find an answer to these questions.  Probably more due to my lack of agility with the search bar of the information being just is not there.  Hope you'll forgive me if.

1. my first question is this.  Say I want to get an output of a command.  I would like to see all the interfaces in the 'ip vrf command show interface' for example.  Not knowing how many interfaces there may be, there could be 10, or there might be 200, what is the best way to limit a loop function after that I gave the following commands?

Set _vrf_int [exec show ip vrf interface]
Set _array_vrf_int [split $_vrf_int '\n']

set $i 0

then {$i< 200}="">
RegExp {([A-Z]+[a-z]+[0-9]+). *} [lindex $_array_vrf_int $i] _complete_string _int
Inc. $i 1

}

Not 100% sure that the syntax is correct, sorry.  If I don't have that 10 interfaces so it won't be necessary to issue this loop 200 times to "$_array_vrf_int".  Also wouldn't be great if I went through the 200 interfaces.  Is there a way I can limit this loop based on the number of lines that were captured after the split function?

2. the value of the regular expression above is output in the var $_int.  Is there a way I can output the regular expression in a table? a ' :-

RegExp {([A-Z]+[a-z]+[0-9]+). *} [lindex $_array_vrf_int $i] _complete_string [lindex $ $i _int]

Syntax is certainly not correct, but I guess there could be a way to do this.  Any thoughts?

3. I did some comparisons on an outing to see if an access list is present on an interface.  I can get a regexp to pull back the name of the access on a given interface list, but if there are any access-list to an if statement on anything?

Set _acl_name 0

RegExp {. * ip access-group (. *) in} $_running_int _complete_string _acl_name

If {$_acl_name! = 0} {puts ' there is an access-list on $_int "} else {puts ' there is no acl on _int $ :-("} "}

In the above output I'm defining the value of ' $_acl_name ' to zero so that I can compare it to the fi statement.  This seems to be a newbie to shit how do however.  Is it a kind of generic I put in place of the '0' to match an empty variable. has ' {null}.

4 I'm sorry last question.  I also reset the variable {null} using a similar wildcard.  Once again I can reset the variable to 0, but it seems just that I do not understand that the syntax well enough and it is without doubt a better method.

5. I have read several tutorials that cover a lot of bases.  Is there a good reference that anyone can suggest so I don't waste your time with these silly questions?  I'm afraid that the scripts I've studied on this forum are always way above my head.

Thanks in advance

Alex

Assume that the limit of the loop.  Which will never end well.  Instead, use a foreach loop to iterate over the number of lines in the output:

set vrf_int [exec "show ip vrf interface"]

foreach line [split $vrf_int "\n"] {
  if { [regexp {([A-Za-z0-9]+).*} $line -> int_name] } {

puts "Interface name is $int_name"

}

}

In addition, do not use the variables that start with "_".  Those that are reserved for the Cisco or overall use.  In addition, 'exec' is a single command tclsh.  If you use the EEM Tcl, you will need to interact with the CLI library.  You can watch our best practices guide at https://supportforums.cisco.com/docs/DOC-12757 for some tips and tricks with the use of EEM.

You can use - all and--inline for regexp all return in a list.  However, given the idea of the loop above, you can also use lappend to each pass:

set intlst [regexp -all -inline {([A-Za-z0-9]+).*} $output]

set vrf_int [exec "show ip vrf interface"]

set intlst [list]

foreach line [split $vrf_int "\n"] {
  if { [regexp {([A-Za-z0-9]+).*} $line -> int_name] } {

lappend intlst $int_name

}

}


You can use "info exist" or simply to check the result of your regexp command to see if a match took place.  See the example above the latter.

regexp {.*ip access-group (.*) in} $_running_int _complete_string _acl_name

if {[info exists $_acl_name]} {puts "there is a access-list on $_int"} else {puts "there's no acl on $_int :-("}

You can 'reset' a variable by using the command 'deactivated '.

One of the best general Tcl references is the "book of the pen:

http://www.Amazon.com/practical-programming-Tcl-4th-Edition/DP/0130385603/ref=sr_1_2?ie=UTF8&QID=1333817448&SR=8-2

Tags: Cisco Network

Similar Questions

  • To loop through the table and use the values returned in another query

    Hello

    I tried to do something very simple, but still can not.

    I am trying to iterate on a table and use each line of a column in a where clause to display a query clause.

    For example:

    I want to retrieve all users of dba_users pass it to a clause where clause in a query to show for example account_status and profile of each user. But I want to do it in a way if I can turn the result in an html table.

    I tried too much really, so I'll post something that does not work, but which I think will show the problem I have,

    BEGIN
     FOR i IN (SELECT username from dba_users order by 1)
     LOOP
     EXECUTE IMMEDIATE 'select account_status from dba_users where username like ''||i.username||''';
     END LOOP;
     END;
     /
    

    Example of what I want to achieve:

    Suppose that there are two users, SYS, and SCOTT:

    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SYS                            DEFAULT                        OPEN
    
    
    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SCOTT                            DEFAULT                        OPEN
    

    Thanks in advance for your time,

    OD

    Hi Bill,

    Bill Citad kirjoitti:

    What a join or a sub query going to help me? honestly

    -- join
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat h join v$sql s on (
      h.sql_id = s.sql_id
    )
    where rownum < 3
    ;
    
    -- subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where sql_id in (
      select sql_id from v$sql where rownum < 3
    )
    ;
    
    -- correlated subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where exists (
      select null from v$sql where sql_id = dba_hist_sqlstat.sql_id
    )
    and rownum < 3
    ;
    
    -- lateral inline view (12c)
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat, lateral(
      select sql_id from v$sql where sql_id = h.sql_id
    ) s
    where rownum < 3
    ;
    
  • generate the search pages the tables and forms using templates speed

    Hello

    I have a table-form page and would like to have a quick search on two windows. Currently, I'm copying the form of generated code page jspx table on page jspx form to achieve. Speed models can be modified to allow this? I looked at the formGroup.vm and the searchArea.vm, but the below lines

    If ($JHS.current.pageComponent.hasSearchArea)
    if(${JHS.) Current.Group.generateSearchAreaInRegion})

    seem to be stumble me...

    We develop in JDev 10.1.3.4 and JHeadstart 10.1.3.3.88

    Thank you!

    Lana

    Lana,

    You can make a custom searchArea.vm and a custom formGroup.vm model where you uncheck the box for #if ($JHS.current.pageComponent.hasSearchArea)

    You will then get a search box in the table and the page of the form.

    Steven Davelaar,
    Jheadstart team.

  • I want to buy a Apple Watch in the Canada and use it and load it in Ireland. Is this possible?

    I want to buy a Apple Watch in the Canada and use it and load it in Ireland. Is this possible?

    Hello

    If you buy a Apple Watch the Canada, it will be completely compatible with your iPhone in Ireland.

    There are no regional differences in the hardware specifications for the watch, which can be configured to use your preferred language and format of the region.

    The included USB adapter pins will be located at the Canada. However, for charging your watch via the food in Ireland, you can use the charge cable provided on the magnetic head with a real 5W Apple (iPhone) or 12W (iPad) USB power adapter. You can also buy an extra Apple USB power adapter for your watch the Apple Store online for the Ireland:

    http://www.Apple.com/IE/shop/product/MD812B/C/Apple-USB-power-adapter?FNODE=83

    Service of the material to the title of the one year limited warranty is also always available in Ireland.

  • Iterator for the table and form is a problem during the cleaning of the records

    Hello

    I use JDev 12.1.2.

    I have an object of the detail view. I represent a part of its fields in a table and the rest in a form. I use the same iterator. Basically, I dragged and dropped the object even from the view of the data control and created a table and form layout with the fields I wanted in each provision. I put in place a clear feature for the rows in the table with a clear"" key. -on click I delete the line of the iterator in the managed bean. When I do this the selected record is deleted and the next record is displayed. But fields entered in the form layout also gets deleted. (the form should also be showing the record currently selected - it shows but entrable fields in the form are deleted because of claire that I did on the previous line.) If anyone can help get this resolved?

    Not use the same iterator for the tables and forms here? The links are in the row (row.bindings...) for the table, but for the form it is (links...). The Delete on the current row operation is causing the iterator delete all fields of links instead of from the line? Please shed some light.

    Thank you

    UMA

    How do you rank on the iterator compensation?

    use resetActionListener in your clear button and let us know what is happening?

    Ashish

  • Is it possible to place the table and the text online?

    Hi all

    I have a table need to align with the numbered list. Is it possible in line of the table and text on a single line. EX: 6.12 and top of the 'text' must align horizontally.

    See the screenshot of the problem.

    Currently what I do, it is to place the table in separate frame and place it online using the option of the anchor.

    Screen Shot 2016-08-30 at 1.20.22 PM.png

    Thanks in advance.

    Kasi

    We could use the options for text blocks to position the first line.
    Fixed value set to 0.

    And a table style that would govern the distance before and after a table.
    If you wish, set both values to 0 .

    We could also do a minimum in the lead with the paragraph formatting to separate paragraph following with the next table.

    Best,
    Uwe

  • differences between the Data Pump to back up the database and use RMAN?

    What are the differences between the Data Pump to back up the database and use RMAN? What is DISADVANTAGES and BENEFITS?

    Thank you

    Search for the backup of the database in

    http://docs.Oracle.com/CD/B28359_01/server.111/b28318/backrec.htm#i1007289

    In brief

    RMAN-> physical backup. (copies of the physical database files)

    DataPump-> logical backup. (logical data such as tables, procedures)

    Docs for RMAN-

    http://docs.Oracle.com/CD/B28359_01/backup.111/b28270/rcmcncpt.htm#

    Datapump docs

    http://docs.Oracle.com/CD/B19306_01/server.102/b14215/dp_overview.htm

    Published by: Sunny kichloo on July 5, 2012 06:55

  • How to set current row in the table after use the button tab on inputText

    Hi all
    My first post.., I am beginner in ADF and I'll try to explain my problem.

    For now we use ADF 11 g (11.1.1.4), in a jsff page I have a table with a column of inputText.
    On the the inputText valueChangeListener, I invoke a method in a bean viewScope that call an EJB method, make some services to the EJB on the modified line. After that, I update the VO and the table (because other values in the row have been changed) and reset the focus on the inputText even modified by the user with javaScript, because the focus was lost after updating.
    So far, everything works fine.

    When I use the arrow keys to change the selected line in the table, this is excellent work (focus is always in the inputText next or previous), but if the user tries the key tab allows you to change the current line, the inputText on the line that has the focus, but the current row in the table is not changed (I think that is normal).

    My question: How can I change the current line after the tab key in this case?

    I don't know if it is really clear, not easy to explain, do not hesitate to ask for more details.
    Thanks in advance.

    Hello

    My question: How can I change the current line after the tab key in this case?

    Use a client event to listen to the keyboard entry and intercept the tab. Use af:serverListener to call the server to set the rowKey on the table and deliver a PPR for the table to repaint

    See example 11 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples

    to learn more on how to use the client listener and the receiving server

    Frank

  • Bigger disk-swapping, but down two, possible to remove them from the table, and then expand?

    I have a R710 with a PERC 6 / i, Win 2008 R2 running. I have a small disk for the operating system, the other 5 bays are filled with 1 TB disks in a RAID array-5.

    I need to add more storage, so I want to buy three discs of 3 TB. I plan on the withdrawal of old readers, and then put it in the new, bigger. I assume that it will take 1 of the 3 TB and repair. Leaving free 2 TB disk. Repeat this step twice more, which will result in three discs of 3TO with 6 TB of disk space not used in the RAID.

    Is it possible to have the controller expand storage in my table of RAID-5 existing free space, and then delete the two remaining 1 TB disks in the array?

    Who is? Is it still possible? Or do I have to backup the data on another storage device and delete the table and simply start a new one with the three discs of 3 TB and copy the data back?

    This will not work:

    (1) the PERC 6 won't take 3 TB drives; the maximum size is 2 TB.

    (2) you cannot delete records in a table - your RAID 5 5x1TB must always have records of 5 or more (you can add without deleting).  Even when using the same number of disks, isn't it possible to do the smaller table/VD.

    (3) even if you used 2 TB disks, there is no way to expand the RAID 5 using the extra space on the disks - with 5 disks in RAID 5, it will remain the same size. The only thing you can do with the new space is to create a second RAID array on the disks (called "slice").  This new VD is handled by the operating system as another "drive."

    Keep in mind if backup and restore in a larger painting, as if the VD ('disc') is greater than 2 TB, the disc "" MUST be converted to GPT and active UEFI bootmode (instead of BIOS).  Make sure that your backup software is capable of restoring one using the BIOS install on a system UEFI (and the 'disc' TPG 'disc' MBR).

  • Popup do not insert in the table and not refreshing called page...

    Greetings



    Environment: APEX 3.1.1.00.09 on AIX 5.3 with 10 gr 2



    I read a lot of threads about my question and I think I'm getting closer to the answer but in some sort have combined a too big number of suggestions and am tripping over my own code.



    Please look at my sample application on apex.oracle.com:



    Workspace: galway

    User: gwicke

    Password: gwicke



    Please start by Page3, select any agency and then click on "add a new contract."

    There are currently a label "BOLD" < facilities > < strong > 'Add new Builder' which is a link that should open a popup window. Type a name in the field, and then click 'Create Builder'. This should INSERT the row into the table builder, close the pop-up window, assign the new name of the generator to the item page calling "Name Builder" and fill the screen element.



    In current state, the application will open the pop-up, allow entry and close by clicking on the button "create Builder." However, the new constructor is NOT inserted into the table and the calling page element is not met.



    Looking at the Page elements and Session State, I can see the correct values assigned to the elements "Pn_BULDER_NAME" on the popup page (4) and the calling page (2), but the value does not appear on the screen.



    I read here where there really two parallel universes, not forgiveness, Articles of two versions of the screen, a State of Session and the other which is displayed in the browser and there are measures to be taken to be sure that is displayed is updated to state of Session I want in this case.



    I entered the Javascript code on Page4 - header to set the 'passBack2()' function and the code in the section "Option URL Redirect" to the button "Add Builder" if all goes well perform protocol ARP for the INSERT, assign items to page 2 and close the pop-up window. He gets not quite everything.



    Any helpp is greatly appreciated. Thanks to Dene for most of the suggestions I have followed by code.



    -gary

    Hi Gary,.

    I think that there is a very simple solution to this topic - is not this spot really last night.

    First, Yes, you could use a "button" to manage the call for the popup - make sure that the button is a type of URL 'button', which is actually an A tag with the appeal under target URL. Otherwise, you could take you existing a tag and use the same class for one of your buttons attribute because this should make it look like a button.

    More importantly, however, I think we could do as:

    1. on your call popup page 2, clear cache for page 4 (the popup page) - I already did in your application by updating the url

    2. on page popup, allow the user to enter their desired P4_BUILDER_NAME value (not sure if you want to do something to make it unique?)

    3 let the user click on create on the shortcut menu. He will submit the page, that will make your P4_BUILDER_RANK (pk) value and insert a new record in the table (you might consider the creation of a sequence and a trigger to handle the creation of new value PK?).

    4 - assuming that the P4_BUILDER_RANK then exist (it would not if there is a mistake somewhere), then conditionally display a region that had a piece of javascript submit page 2 and closes then itself - we don't need to move everything back to page 2 (see below)

    5. as the P4_BUILDER_NAME and the P4_BUILDER_RANK exist in the session, to which page 2 be reloaded, (A) the selection list should be updated with the new generator (still not sure why all my entries appeared downstairs instead of in alphabetical?) and (B) the P2_BUILDER_NAME and the P2_BUILDER_RANK can have Post calculation calculations together (NVL) ((: P4_BUILDER_NAME,: P2_BUILDER_NAME) and NVL (: P4_BUILDER_RANK,: P2_BUILDER_RANK) respectively)-l' effect is, if there are the values stored in the page P4 elements, we use them, otherwise, we use whatever values were in the elements of page P2

    6 - Finally, to stop (5) that happens in all the loading of page 2, you would need to clear the cache of page 4 in as many places as possible - for example, branches for a 2 page or buttons on page 2

    The reason why we cannot pass values back to page 2, it is one of the elements is a list of selection. The value we want to select will appear not on the selection list until the page has been sent. So, we can set the value and submit because the value is not there. We can introduce and define the value, because the javascript don't know when the page has been updated (or, at least, you need an independent mechanism to identify, which can get complicated).

    So, in other words, as long as we know that if the values are in the session, we can use Post calculation calculations to set our fields to these values. The only thing to keep in mind is that we must ensure that these session values only exist when in need - so we empty the cache. This principle should work for any type of terrain - but as you have no doubt seen, simple text fields can be updated by the popup directly as the field must accept any value that we give.

    My only recommendation would be to completely remove the MRU of the page process because they are not necessary (they simply confuse the issue) and you could make your fetch PK and record insert into a single process - just to keep things clean and tidy, you understand!

    When I finished last night with your app, I will leave so that javascript can create an option on the select list, and then set the value. But the method described above seems to be much simpler.

    Andy

  • Will buy the Xoom and use with MIFI

    I intend to buy the Xoom and use it only with Mifi (on the road) and my wireless router (at home), if I have to buy with Verizon CDMA, I'll do it, but I don't intend to start a plan with Verizon, I hope that it works for the units that are selling from 02/17/11.

    The XOOM has wifi, so your Mifi will work with him. you wouldn't buy a package given just the XOOM.

  • When my battery is fully charged, what button I press to turn off the battery and use the DC

    When my battery is fully charged, what button I press to turn off the battery and use the DC. I need to know what to do to avoid the impoverishment of my battery. OR is it save to leave the computer on, even when the battery is fully charged

    Well, actually from what I read, it's correct exactly as it goes, but not a complete list of the maintenance of the batteries all the factors, methods, practices and details regarding the definition of periodicals.

    While he was just more info not really part of what has been requested, this is why I don't give him properly a collection, I appreciate that you expand on it with greater precision.

    It is not often that one of my messages is considered as not long enough.  :-)

    Thanks for the help.

  • I can stream movies on my PC using the desktop PC monitor. But when I unplug the monitor and use a PC to TV HDMI cable I get the video but the audio now

    . Video streaming

    I can stream movies on my PC using the desktop PC monitor. But when I unplug the monitor and use a PC to TV HDMI cable I get the video but the audio now... Suggestions?

    Thanks for the file INF. I ck'ed for driver updates and I have the latest drivers installed.  I got the sound working on the TV by hanging the audio output of the PC to the entrance of the TV with the HDMI cable in place for video. It's the simplest solution to this problem, so I took it.

    By the way, I have a Dell 620 with windows 7.
  • I have all the games Age Of Empires, the versions of Windows and I changed to a Mac computers. How can I get the Mac version of the games and use my existing serial keys?

    I have all the games Age Of Empires, the versions of Windows and I changed to a Mac computers. How can I get the Mac version of the games and use my existing serial keys?

    Hello

    As you have bought Age of Empires for Windows OS, you will not be able to install the same copy of Age of Empire Windows version on Mac. However, you can contact the telephone support for confirmation on this issue.

    Here is the link:

    http://support.Microsoft.com/kb/295539

  • How to create a grid with the tables and Boolean values?

    As part of a larger project, I'm trying to create a Subvi, which will allow me to spend a "cursor" in a 3 x 3 matrix.

    It should be 2 Boolean inputs, one for move them down in the table and the other to move them to the right. Once reached the edge of the table, the "cursor" will start back at the beginning.

    I have a vague idea of a table to 2 dimensions with LED. Once 'down' has been selected, the corresponding light to (0,0), light (0.1). Goes the same for the button 'right '. When 'down' is pressed (0.2), the LED should turn off, and LED (0,0) must light up.

    I'm sure it has something to do with the initialization of the tables, but I can't seem to find the right way to do it.

    Any help is much appreciated. Thank you!

    Your array is always empty.  Look at the detailed help for the function page replace table subset.  He says that the function has no effect if the specified index refers to a location outside the table.

    What you see on the Panel is only a view and has nothing to do with what is in the table.

    Lynn

Maybe you are looking for

  • If I had to close all my toolbars, toolbars, menu and navigation, bookmarks, how can I open them back up?

    I have reduced all my toolbars, navigation, menu and bookmarks toolbars, but now I can't open them up. I tried to remove storedinfo and opening safe mode, but the toolbars are all simple disappeared. I tried to do a right click on the space, but he a

  • Problem NVIDIA Tecra M5

    A couple of days, I got a blue screen with a message This nv4_disp was in a permanent loop. Following the instructions on another forum, I deleted the Nvidia files in safe mode. I also installed a The computer is now working again, but has some probl

  • Text messages are dumb

    What does it mean when text messages are dumb?

  • Encender UN LED con NI9477

    Hola tengo una pregunta compañeros there will me apoyaran an aclararla,. Desarrolle una con application el modulo 9477 salida digital para encender y apagar how United Nations LED, the application works perfectly, oprimo UN boton en el Panel frontal

  • Text no autosize in PDF form

    HelloI use Acrobat Reader for Macintosh to fill out a PDF form for a University assignment. On previous assignments, I was able to type in a form field, and the text would be autoshrink to account for the size of the field that I completed my answers